SOProtocol: Open dialog and automatically add person, company and sale

lock
push_pin
done
Besvart
11

Hi,

We are working from a webpanel on the SuperOffice logo, and we need to open the dialog window to create a new appointment with pre-filled data.

We can open up specific appointments just fine with:

SuperOffice.ClientCrossMessaging.executeSoProtocol('appointment.main[refresh=false]?appointment_id='+id);
 
But, when running the following code, the Sale is not populated (but, it works when we are actually standing on the sale in the gui)

SuperOffice.ClientCrossMessaging.executeSoProtocol('appointment.main[new=true]?appointment_id=0&sale_id=12345');

How can this be achived?

Regards
Pär Pettersson

6. nov. 2024 | 03:35 p.m.

Alle Svar (11)

Based on the documentation, this currently isn't possible.

6. nov. 2024 | 06:52 p.m.

Hello Pär, 

David is almost correct, and our documentation does not state that you can add sale_id. 
But, you can use the `usesalecurrent=true`, which will let you set the sale_id. So you should be able to do this:

postMessage({ command: "soprotocol", arguments: "appointment.main[new=true]?appointment_id=0&sale_id=1&usesalecurrent=true" }); 

Sorry if this is a little confusing, I'm currently working on rewriting this part of our documentation to (hopefully) make it more clear.

Have a SUPER day!

//Eivind

26. nov. 2024 | 02:32 p.m.

Wow, it does work!  :)
Thanks alot!

Regards

Pär

27. nov. 2024 | 07:39 a.m.

Hi again,

One would guess that the same goes for the Document dialog, but, it does not.

document.main[new=true]?document_id=0&sale_id='+saleId+'&usesalecurrent=true

How do we achive the exact same thing for Documents?
 
Regards
Pär

 

11. des. 2024 | 10:57 a.m.
See this document here, not yet merged into Docs so not available on docs.superoffice.com (yet):

https://github.com/SuperOfficeDocs/superoffice-docs/blob/7825d2ef5c11a8a176598db4a1fd09debb917831/docs/en/ui/soprotocol/howto/create-document.md
11. des. 2024 | 10:58 a.m.

Thanks for the link, although, does not work.

SuperOffice.ClientCrossMessaging.executeSoProtocol('document.main[new=true]?document_id=0&sale_id='+saleId)
The following does not set the saleId
11. des. 2024 | 12:08 p.m.

Hello Par, 

Sorry, but while rewriting this section on docs we discovered a couple of bugs/issues which we are still trying to figure out.. 
It has to do with how the old pagebuilder worked, and how it now is SCIL-based instead, and I see some of the issues are still not resolved completely. 

The tl;dr is that you cant do the same for document as you can on followup, as the usersalecurrent/useprojectcurrent dont exist there..
A bonus-quirk is that if you are currently on a sale in SuperOffice, then you are able to set default sale (as you are trying to do) in the document-dialog. 

Sorry!

//Eivind

12. des. 2024 | 08:00 a.m.

Ok good to know, thanks.

If you remember, and when this is fixed, please let me know in this thread :)

(We are releasing activity+document support in Salesboard today (an App), and the last key was to be able to set the Sale in the document dialog directly by an ID)

But, as long as we know, we can ship everything else, so all good :)

Regards
Pär

12. des. 2024 | 08:20 a.m.

Another issue, it does not really seem to be possible to load documents?

According to the documentation it should be: document.main?document_id=X

But, it just opens the last document open in S&M, not the actuall documents with that id.

document.main[refresh=true]?document_id=X does not work either.

Any suggestion?

Regards
Pär

16. des. 2024 | 07:26 a.m.

Hello Pär, 

This works for me, in SOD:

postMessage({ command: "soprotocol", arguments: "document.main?document_id=3" }); 

In what context are you executing this command? I've tried to execute it while standing on company, sale and project, but maybe there is something with how/where you are in the application?

//Eivind

16. des. 2024 | 07:44 a.m.

Got it working with: SuperOffice.ClientCrossMessaging.openDocument(id);

The postMessage didnt do anything, i guess its because of Cors since the code is running from another domain in an webpanel on the superoffice logo.

All good, thanks alot for your fast response!

Regards
Pär Pettersson

16. des. 2024 | 08:33 a.m.

Legg til svar