Open contact in SuperOffice S&M

Hi guys,

Can somebody explain how the button "Open in SuperOffice CRM" for a given contact in Service works?

As far I can see, the button references to the following url: 
http://cs.test.dk/Sale/default.aspx?contact.main.activate?contact_id=

I would like to implement the same functionality for a different context.
Tried to create an Extra Menu that adds a button to a Extra Table screen that calls a CRMScript.

Doing so, SuperOffice CRM shows the contact with rank 1 in the history list.

Tried different scenarios, including changing the history list with CRMScript, but none of them works. The history is changed in SQL, but the change is not applied to the list in S&M.
Environment: OnSite v. 8.1

CRMScript for redirecting to the contact id:

String id = getVariable("entryId");

SearchEngine se;
se.addField("y_potential.x_contact_id");
se.addCriteria("y_potential.id", "Equals", id);

if(se.execute() > 0)
{  
  setVariable("url", "http://crm_tst.ok.dk/Sale/default.aspx?contact.main.activate?contact_id=" + se.getField(0));
  flushCaches();
}
 

CRMScript including changing the history list:

#setLanguageLevel 3;

String id = getVariable("entryId");
String aid = getVariable("activeAssociateId");

SearchEngine se;
se.addField("y_potential.x_contact_id");
se.addCriteria("y_potential.id", "Equals", id);

if(se.execute() > 0)
{
  SearchEngine seh;
  seh.setLimit(1);
  seh.addField("History.history_id");
  seh.addCriteria("History.associate_id", "Equals", aid);
  seh.addCriteria("History.table_id", "Equals", "5");
  //seh.addCriteria("History.rank", "Equals", "1");
  seh.addOrder("History.rank", false);
  
  if(seh.execute() > 0)
  {
    NSHistory history;
    NSViewStateAgent view;
    history = view.GetHistory(seh.getField(0).toInteger());
    history.SetId(se.getField(0).toInteger());
    //history.SetRank(1);
    view.SaveCurrent(history);
  }
  
  setVariable("url", "http://crm_tst.ok.dk/Sale/default.aspx?contact.main.activate?contact_id=" + se.getField(0));
  flushCaches();
}
 

Has anybody tried to replicate this functionality?
Thanks in advance.

/Kim

RE: Open contact in SuperOffice S&M

Hello, 

I have stumbled on the same issue. 
The issue looks to be that ? is replaced with & in the URL. 
This code (in my case opening a newly created Project): 

setVariable("url", "https://online.superoffice.com/cust10875/default.aspx?project.main.minimonth.projectmemberarchive?project_id=" + pEntity.GetProjectId().toString()); 

Comes out like this: 

https://online.superoffice.com/cust10875/default.aspx?project.main.minimonth.projectmemberarchive&project_id=60


It looks like all "?" are auto-replaced with "&" after the first "?" (in this case, default.aspx).
Since the URL is invalid it loads the last history item intead. 

Anybody else seen this, and have a workaround? 

//Eivind

Av: Eivind Johan Fasting 4. jun 2018

RE: Open contact in SuperOffice S&M

Eivind, in URLs ? is only supposed to be added once. For all other cgi variables & is used.

I.e: http://www.url.com/page.html?firstKey=value&secondKey=value&thirdKey=value

Using ?firstKey=value?secondKey?value?thirdKey=value isn't a correct format.

Av: Simen Mostuen Iversen 7. jun 2018

RE: Open contact in SuperOffice S&M

Hello, 

The problem is that this IS the correct format in Sales. 
If i open a project the url looks like this: 

.../Sales/default.aspx?project.main.miniday.guide?project_id=9351 

you have '?' on both ends of project.main.mainday.guide. 
The same goes for contact, sale etc: 
.../Sales/default.aspx?contact.main.miniday.personarchive?

To explain the scenario: 
I create a button in Sales on the left, this button runs a CRMscript. 
This opens a new window, creates a new project (and sets some values etc), and opens this project in the new window. 

I am unable to open the newly created project with setVariable, it opens the last history item (or tries to open projectId=1, not sure) instead, and that is because the URL is invalid with '&' instead of '?' on the end of project.main.mainday.guide. 

//Eivind

Av: Eivind Johan Fasting 7. jun 2018