Application Programming Interface forums

0 Abonnenter

3 Emner

4720 Samtaler

Area for questions and answers about SuperOffice API's.

push_pin lock

The new Dialog functionality not working on the Document Dialog

Hi All, Are we aware of the issue where the new dialogs not working on the Document Dialog.  The following sample piece of code works on the Before and After Save or the Appointment, Sale and Project entites (I am sure it would work on Company and Contact, but I have not tested this).  However when using this script on the Document Before and After Save events, the dialog just does not show.  The script fires, and can see it in the trace, but the dialog is not displayed. #setLanguageLevel 3; EventData ev = getEventData(); EventDataDialogDefinition dialog; dialog.setTitle("Update Active Documents"); dialog.setType("yesno"); dialog.setIcon("question"); dialog.setPrefix("confirmUpdActDocuments_"); dialog.setText("There is already an active document for this document type and project. Do you want to make remove the active document status from the previous documents?"); ev.showDialog(dialog); The only dialog I can get to show for the document is the ev.setMessage,  I have tested this on the latest on site release of SuperOffice, and with SuperOffice online.  Does anyone know when this will be available, I have a script to write for a customer that requires this, and at the moment I cannot get this to work. Many thanks, Trevor  
Trevor Sharp
4
11
19. mai 2023 | 11.04 a.m.
Emne:
Service and CRMScript Discussion

Siste svar

Perfect, thanks David, I will give this a go.
by Trevor Sharp
6 t, 56 m siden | 02.54 p.m.
push_pin lock

How to post a NSDocument Stream as multipart/form-data

Hi, We have built interaction between SuperOffice and Trello. We create cards and get statuses and such. Now I want to build a function that gets NSDocument from a Sale i SuperOffice and post it as an Attachment to a Trello Card. I have made successful posts and puts with the HTTP CRMScript class, but I can't figure out how to post a NSDocument Stream according to the Trello Instructions. https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post It needs to be posted as multipart/form-data with a parameter/name of "file".   I have tried this, with no luck: HTTP h2; Bool addeddoc = h2.addDocumentData(8859); h2.addHeader("Content-Type","multipart/form-data"); Byte[] b2 = h2.post("https://api.trello.com/1/cards/" + trelloCardId + "/attachments?key=***************&token=*********************************7"); if (h2.hasError())   print(h2.getErrorMessage()); else {   printLine(String(b2,"utf8").utf8Decode()); } I get error "Error parsing body" Any ideas? 

JT

John Tilly
2
1
26. mai 2023 | 06.46 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

Hi John, I had the same issue with adding attachment data as multipart/form-data, see this thread . addDocumentData/addAttachmentData does not work since that is not added as multipart/form-data to the http body. Sadly this is not solveable (currently) within CRMScript. I did register a wish for it.
by David Hollegien
8 t, 35 m siden | 01.15 p.m.
push_pin lock

GetSaleDocuments renders no results

Hi, I am running below code. It does not give any results. Even though the sale has documents. CRMScript: NSDocumentAgent documentAgent; NSDocument[] saleDocuments = documentAgent.GetSaleDocuments(SALEID); printLine(saleDocuments.length().toString()); for(Integer i = 0; i < saleDocuments.length(); i++) { String documentUrl = documentAgent.GetDocumentUrl(saleDocuments[i].GetDocumentId(), "", true); printLine(documentUrl); } C# var documentAgent = new DocumentAgent(config); var saleDocuments = await documentAgent.GetSaleDocumentsAsync(saleId); What am I doing wrong? NSDocument[]  and  saleDocuments are empty in both cases.    The Sale has documents:

JT

John Tilly
2
4
25. mai 2023 | 10.41 a.m.
Emne:
Online development and web service API's

Siste svar

Hi, Thank you for clearing that out!  I will do some tests.  Have a nice weekend!  

Community.Data.Models.ForumConversationDetails?.AuthorInitials

by John Tilly
26. mai 2023 | 02.36 p.m.
push_pin lock

Update supportLanguageId failes

Hi, I'm trying to update supportLanguageId for contacts according to below SearchEngine SearchEngine se1; se1.bypassNetServer(true); se1.addData("person.supportLanguageId","2"); se1.addCriteria("person.contact_id.userdef_id.string01", "OperatorBeginsWith", "K"); se1.addCriteria("person.supportLanguageId", "OperatorEquals", "0"); se1.update(); It gives me below error, If I do an execute I get a list of contacts. I have tried removing bypassNetServer but i didn't help either. Any ideas how to solve this? Thanks!
Johan Friberg
3
4
25. mai 2023 | 01.27 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

Thanks! This is what I ended up doing after Espens comment.
by Johan Friberg
26. mai 2023 | 06.54 a.m.
push_pin lock

Small announcement: new CRMScript method: pauseTracing

Hi all, I don't know about you, but personally I use the script tracing functionality quite often. Often I just leave it on when I have created something, and then tell the customer to notice the exact time if something fails. Then I can go back, find the trace, and see what happened. However, one problem with tracing is that if you do something inside a tight loop, such as quering the database, you will get a lot of trace frames which pollute the result (and sometimes it will get cropped because the trace is too large). And viewing the trace gets cumbersome with all those not-so-interesting frames. So, I just create a new small function: pauseTracing(Bool), which you can put in your script around stuff you don't want to trace. It has an internal counter, and only traces when it is zero. So multiple calls to pauseTracing(true) must be matched with an equal number of calls to pauseTracing(false). Just place those around stuff you don't want to trace like this: Void doStuff() { SearchEngine se; se.addFields("ticket", "id,title"); se.setLimit(10); pauseTracing(true); for (se.execute(); !se.eof(); se.next()) { titles.append(se.getField("ticket.title") + ","); } pauseTracing(false); } If a script is not being traced, then this call will have no effect. So you can just leave it in your production code. Available from our next release, 10.2.6. Sverre
Sverre Hjelm
2
2
19. mai 2023 | 02.09 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

Fantastic, experiences this within 10 minutes of seeing this post. And since we do alot of quite big restcalls, we see this alot.
by Pär Pettersson
23. mai 2023 | 12.06 p.m.
push_pin lock

How do I avoid trigger "Service: Saving a request" to fire several times?

I have a trigger on 'Service: Saving a request' which post data to a webservice. But we see that sometimes data is send send several times right after each other. I expect the trigger is fired (like if it was a webhook) by different areas of the SuperOffice code updating the ticket/request. Since I do know where or why I have tried to prevent it by indicating that my code is allready running and should not run again (until finished). A) Setting eventdata state using ed.setStateValue ("running","yes") B) Setting global variable using setGlobalVariable("running","yes") Ex like this: String working = getGlobalVariable("running"); if (working == "yes") {   return; } setGlobalVariable("running","yes"); <post to webservice here>   But I have no success, maybe the code actually is able to finish before the next time it is fired. but... I never clear the variable. How do I prevent it from running again sending the same data?    
Morten Larsen
1
4
28. apr 2023 | 06.18 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

It turned out that 'Service: Saving a request' was fired even when users where just looking at a ticket. Ie I ended up using extratable to check if current data had allready been send.  
by Morten Larsen
17. mai 2023 | 01.20 p.m.
push_pin lock

Set the active company and contact when creating a new appointment in CRMscript

Hi I have made a new screen in SuperOffice Service, that the users of SuperOffice uses to create a new project. On the screen the user writes a text (which is the name of the project) and finds a contact. This contact is then made a project member. Then the screen exits back to SuperOffice on the newly created project. The above works as it should, but when the users create a new appointment, the “default” company and contact is the one they used last time in SuperOffice CRM. I would like this company and contact to be the one they selected as the project member. Does anyone know if it is possible to set the “active” company and contact name, and how it is done in scripting? /Thomas

TK

Thomas Kragh
2
4
16. mai 2023 | 06.31 a.m.
Emne:
Service and CRMScript Discussion

Siste svar

Thank you so much David. That worked like a charm.  

Community.Data.Models.ForumConversationDetails?.AuthorInitials

by Thomas Kragh
16. mai 2023 | 02.46 p.m.
push_pin lock

Breaking change related to Customer portal authentication

Hi all, Today we have been made aware of a problem with customer login for customized customer portal sites that we are currently fixing. Let me share some details on this. For the latest release, we have modified the authentication for customers (used for the portal login). We did this for security reasons, since hashing algorithms and brute force power have evolved since the old implementation was done. As a consequence, we also removed the Customer.getValue("password") CRMScript method and rewrote all places it was being called in our code. The idea was that there was no good reason to expose the encrypted hash. What we did not know is that the CRMScript library shared on github is actually using this functionality to authenticate a customer, by using setValue("password") and getValue("password") on an unsaved customer to calculate the hash. Now, this method would have failed with our new encryption anyhow, because our current solution is also salting, which means the hash will vary randomly for a fixed password. The solution we have decided to implement, and that we are currently building and will roll out to affected customers as soon as possible, is a new CRMScript method: Integer authenticateCustomer(String username, String password) We believe this is the correct solution to your requirement: being able to authenticate a customer. It does not expose the hash, but it lets you check whether a username/password combination is valid. If so, it will return the personId of the customer. It not, it will return a null-Integer. This means that you will need to update any customizations you have using the old lib-auth method to the new method as soon as a customer is upgraded to the new version. We sincerely apologize for the inconvenience. We were not aware that the getValue("password") method was being used for this purpose. Please get in touch with us, or reply to this post if you have further feedback or need assistance related to this. Sverre  
Sverre Hjelm
4
9
15. mai 2023 | 02.54 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

Ah, ok. It would have been nice to do something like this: Customer c; c.authenticateCustomer("eivind", "theawesome"); c.getValue("firstname"); But returning the personId is also good :)
by Eivind Johan Fasting
16. mai 2023 | 10.20 a.m.
push_pin lock

Archiving emails sent through CRM Script

Hi All, We often use CRMScript to send emails out of SuperOffice.  The formatting flexibilty with the reply templates, and the fact that you can send out links to SuperOffice forms with the custSessionKey included is really useful. But we are often asked if we can archive the email we have sent via CRMScript against the recipients record in SuperOffice.  I certainly do not know of a way of doing this, but does anyone know if is it possible to do this, and if yes, how I would go about doing this? Many thanks, Trevor
Trevor Sharp
1
4
20. mar 2023 | 03.52 p.m.
Emne:
Service and CRMScript Discussion

Siste svar

I have solved this issue by creating an appointment on the contact (You have everything you need to know like time, date, type etc.), and then set the content from the mail in the appointment. You "only" have to decide which SuperOffice user you will add this to (we use our primary SuperOffice contact for the company) I know this isn't saved as a document, but the mail/text is easy to find (also appears in search) in SuperOffice CRM. /Thomas

Community.Data.Models.ForumConversationDetails?.AuthorInitials

by Thomas Kragh
16. mai 2023 | 06.38 a.m.
push_pin lock

Undocumented change to the Customer Object?

Hello,  We have created external customer centers for some of our customers, and have created custom CRMscripts to handle the authentication (pass inn username and password) so that we can use the customers that is registered inside SuperOffice.  We have leveraged the method that has been a part of the lib-auth on github to handle this:  CRMScripts/lib-auth.crm at master · SuperOffice/CRMScripts · GitHub   Today, or more likely after this weekends update of online, this is now broken, and after some quick tests its not longer possible to getValue("password") on the customer-object. This means nobody can log in to the customer center anymore.  We cant see any reason why this is now changed, and I'm unsure if its a BUG or an intended fix of something that should not have been an option (?) Has anyone else experienced the same, and have anyone been able to find a workaround?  The only option, as I see it, would be to use the new method on the PersonAgent, POST Agents/Person/GetUserCandidateByPerson | SuperOffice Docs , but that requires the personId, so it would mean we have to first lookup the person by username, then pass the personId to this new method to get the password.  It is also a question about how this would look when used through a CRMScript. I expected something like this to work:    If i pass in the id of a person here it looks OK, but i unfortunately dont know what methods are available on NSUserCandidate as there is no intellisense for it..  //Eivind
Eivind Johan Fasting
1
5
15. mai 2023 | 08.24 a.m.
Emne:
Service and CRMScript Discussion

Siste svar

Made a new post for this to make sure I got everyone's attention :-) Breaking Change Related To Customer Portal Authentication
by Sverre Hjelm
15. mai 2023 | 02.55 p.m.