Application.SetProtocol does not work or the protocol string is wrong

Hi,

Have a windows script that stopped working after upgrade to SO 8.3

This does not work

Application.SetSoProtocol("superoffice:document.details?document_id=0&edit" )

Expected result is: The document dialog should open.

Best regards

Patrik Lindholm

RE: Application.SetProtocol does not work or the protocol string is wrong

From where do you issue the call? What is the context?

Have you tried PostSoProtocol?

Af: Tony Yates 21. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

I tried this from an external vbscript:

------------------------

Set app = CreateObject( "SuperOffice.Application" )
If Not app Is Nothing Then
    app.SetSoProtocol("superoffice:document.details?document_id=0&edit" )
Else
    WScript.Echo "Error getting application object"
End If

--------------------------

 

Works for me on my latest 8.3.
What version are you running and may be Tony is on to something, what is your context?
/conrad

Af: Conrad Weyns 21. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Hi,

The entire script looks like this:

Sub OnCurrentSaleCreated()
    SaleTitle = CurrentSale.Title
    CurrentSale.Title = CurrentSale.Number & " - " & SaleTitle

    CurrentDocument.SetDefaults
    CurrentDocument.Sale = CurrentSale
    CurrentDocument.Contact = CurrentSale.Contact
    CurrentDocument.Person = CurrentSale.Person

    Application.SetSoProtocol( "superoffice:document.details?document_id=0&edit" )
End Sub

When a sale gets created there is a slight change to the sale itself (add number) and then the document dialog is supposed to show.

Works fine up till 8.2 r06. But has stopped working in 8.3 (customer runs 8.3.6718.18)

Af: Rikard Fredlund 25. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Hi,

Have tried PostSoProtocol and it does not work either.
The difference is that the sale goes into edit mode, that does not happen when using SetSoProtocol.

If I run the protocol string from the run box in windows it works so there is no error there.
If I change the script, the first time it is run I get a message saying:
"Protocol handler(s) already registered for:
                      document: (?), C_EDIT_DOCUMENT_FROM_ID
                      newdocument: (?), C_REQUEST_NEW_DOCUMENT"

 

Best regard

Patrik

Af: Patrik Lindholm 25. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Upgraded to SO 8.3 R2

No change in behaviour.

Best regards

Patrik

Af: Patrik Lindholm 25. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Hi!

I'm a little curious as to why you would be calling CurrentDocument.SetDefaults without setting the current document to a new document first? 

I'm reminded of this post from 2006, and here is how that script looked (with one modification):

Sub OnCurrentSaleCreated 

    Dim enTableDocTmpl
    Dim enCtxDocumentOnly

    enTableDocTmpl = 130
    enCtxDocumentOnly = 11

    CurrentDocument.ChangeIdentity 0
    CurrentDocument.SetDefaults

    'SetContext 0, enCtxDocumentOnly ' old way
    SetSoProtocol("superoffice:document.details?document_id=0&edit" )
    
    CurrentDocument.Contact = CurrentSale.contact
    CurrentDocument.Person = CurrentSale.person
    CurrentDocument.Project = CurrentSale.project
    CurrentDocument.Header = CurrentSale.SaleText
    CurrentDocument.Description = CurrentSale.SaleText
    CurrentDocument.Template = GetListItem(enTableDocTmpl, 2)

End Sub

Hope this helps!

 

Af: Tony Yates 25. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Hi,

I have added tfs 59557: Win: Problem opening a new document dialog from inside OnSaleCreated
There seems to be several issues here. Much has changed between 8.2 and 8.3. 8.3 is the one we put all our efforts in.

I will look into this for the next Win 8.3 release which should be R04 after the summer vacation.

 

That said, on a different but not related note, the following is not supported from inside a SaleCreated message:

      CurrentSale.Title = CurrentSale.Number & " - " & SaleTitle

You must use the *BeforeSave events to further change any fields for a Create/Save.
It may have worked simply because the model may have been reset to dirty and will undergo an implcit Save-On-Change-Identtity at some point later on. Any way, not good practice. If it worked, you had luck on you side.

Have a nice summer vacation everyone!
Conrad

 

There is a work-around:

Do not try to set the Current document defaults.
Actually, the soprotocol will override it anyway!

This snippet works for me with my latest 8.3.:

Sub OnCurrentSaleCreated()
SaleTitle = CurrentSale.Title
CurrentSale.Title = CurrentSale.Number & " - " & SaleTitle
Application.SetSoProtocol( "superoffice:document.details?document_id=0&edit" )
End Sub

The defaulters have changed much. 
Also, note that 8.3 has new OnCurrent*Defaults messages e.g OnCurrentDocumentDefaults.

Just let the SoProtocol handler do it's thing with regards to the current document.
Note that I have left the CurrentSale.Title = line in. Though you will see the Sale number pre-pended to the sale name and also in the Sale dropdown of the document dialog, it is not yet saved to the database!
The model will leave the Create/Edit phase in a dirty state. 

I have identified the problem with the document defaulter when called from COM.
It needs to know if it is on behalf of the <Application> instance or the <SuperOfficeDB> instance. My bad :-)

 As I said, much has changed with the defaulters due to the stand-alone Person Card and support for "Orphans" (Person whose contact id = 0)
 
Will be fixed during the summer!
/conrad.
Af: Conrad Weyns 25. jun 2018

RE: Application.SetProtocol does not work or the protocol string is wrong

Hi,

I got it working now.

Conrad & Tony thanks for the help.

Best regards

Patrik

Af: Patrik Lindholm 26. jun 2018