CRMScript now available for Sales in Online

Hi all,

We are pretty excited about our latest online release, which should be available this week. In this release, we have added support for CRMScript for various events in the Web Sales client. For instance, you can use this to block users for registering a Company with insufficient information, or send an email every time a new Sale is registered.

We will get more information ready over time, but just to get you started, here is quick example. You need to have the Expander Services license and be a General Administrator to get access to this.

Go into Web Admin, and you should see a new navigator menu option: CRMScript. Click here, move to the "Event handler" tab, and create a new Event handler. Choose "Sales/Before save company" as the event, and add the following code:

 
#setLanguageLevel 3; 
EventData ed = getEventData(); 
if (ed.getInputValue("ContactEntity.Department") == "") { 
  ed.setBlockExecution(true); 
  ed.setMessage("Department cannot be empty!"); 
} 

Save the event handler, and try editing/creating a company and with an empty department. You should get an error message in a dialog, and the save should be blocked.

I am sure you will find some quirks we need to work out, and most likely you will have ideas to further improvements of this. Still, I hope this will be a valuable tool for you to customize CRM in online :-)

RE: CRMScript now available for Sales in Online

I feel this best describes how I'm feeling:

*Hooray!

Av: Hans Wilhelmsen 16. aug 2017

RE: CRMScript now available for Sales in Online

Very nice, can't wait to hear more about this !

Av: Henk Schepers 16. aug 2017

RE: CRMScript now available for Sales in Online

Very cool! This is going to be extremely usefull!

Those handful lines of codes would have taken us at least 10 times as long to do in C#, and we would have had to log into the server, replace files, do an IIS-reset, etc. But with ejscript we can do this in seconds on the fly. This will be used a lot!

One comment - the rules are enforced when editing company in Sales, but not in Service. Any thoughts on getting Service to execute the same event-scripts?

Av: Frode Lillerud 16. aug 2017

RE: CRMScript now available for Sales in Online

This is great, thank you!

Av: Pär Pettersson 16. aug 2017

RE: CRMScript now available for Sales in Online

Woohoo :) This is awesome

Av: Simen Mostuen Iversen 17. aug 2017

RE: CRMScript now available for Sales in Online

Awesome, great work guys! 

Av: Matthijs Wagemakers 17. aug 2017

RE: CRMScript now available for Sales in Online

endless possibilities! Great news!

As a sales guy I would love to have some working examples which we can use in our demo's.

Some ideas:

- after a document of a certain type has been created a follow-up activity is automatically created (follow-up after quote)

- after an appointment of a certain type has been completed a follow-up activity is automatically created (visit report after visit)

- certain fields of a company card with a certain category cannot be altered
(customer cards are managed by ERP Integration and adress fields may not be altered in CRM)

Anybody interested in creating such examples? We will send chocolate :)

Av: Joost van den Bogert 17. aug 2017

RE: CRMScript now available for Sales in Online

Great news! Lot's of new opportunities for customers and unlimited power for our consultants. Thanks Sverre!

Av: Maarten Reuser 17. aug 2017

RE: CRMScript now available for Sales in Online

Sverre, two questions.

1) Have you considered the scenario where we need to get feedback from the user via a dialog? For example, we want to display a Yes/No dialog to ask the user if we should create a followup appointment.

2) (Redirect the question to one of the NetServer guys if this is their domain) In the event "Before Appointment Save" I listed out all the values (which is quite a lot), but did not find a value for the "Completed" state of the appointment. I was expecting there to be a "AppointmentEntity.Completed" value in the .getInputValues() map. An oversight?

Av: Frode Lillerud 18. aug 2017

RE: CRMScript now available for Sales in Online

Awesome news, Sverre!!! This is a great deal! :)

Looking forward for more information!

Av: Kim Long Nguyen 18. aug 2017

RE: CRMScript now available for Sales in Online

Wow, this is opening so much new possibilities!!

Av: Niels van Broekhoven 18. aug 2017

RE: CRMScript now available for Sales in Online

Frode,

Yes, we are aware that there are more needs. Our current implementation is v1.0, using the currently easily available functionality. I am sure we will add more advanced functionality down the row. But for now, you do not get to ask questions (in a dialog) ;-)

I will look into the Appointment.Completed value :)

Sverre

Av: Sverre Hjelm 21. aug 2017

RE: CRMScript now available for Sales in Online

Great news Sverre.

More examples how to use would be appreciated.

Is it for example possible to use this technolgy to make a default field like "Code" uneditable?

Or to make the field department have a red mandatory color so the user can see it is mandatory before he press the save button?

Is the functionality also available for on premise customers?

Av: Gustaf Cullin 28. aug 2017

RE: CRMScript now available for Sales in Online

Hi guys,

We will provide better documentation as soon as we can. In the meantime, some additional info:

What inputValues() you receive is dependent on the event, as well as your configuration (e.g. extra fields). The easiest way to see what is available, is to debug an event handler, or log the data: 

log(ed.getInputValues().toJson());

Run the event (e.g. save the company), and the have a look at your logfile, either on disk or by using rms.fcgi?action=newLog&date=2017-08-29.

Currently, the feedback to the UI is very limited. The only things you can do are:

  • Block the save in the pre-save event handler: setBlockExecution(true);
  • Modify values in the UI: setOutputValue("field", "value"); Only some fields are supported, using same "path" as inputValues.
  • Navigate the client using SOProtocol.
  • Show a message.

Sverre

Av: Sverre Hjelm 29. aug 2017

RE: CRMScript now available for Sales in Online

Hi Sverre,

I get this error message regardless which event handler I use.
Do you have any idea, why this error occurs?

And the CRMscript is simply a copy of your code-snippet.
Is there a bug?

 

Av: Kim Long Nguyen 1. sep 2017

RE: CRMScript now available for Sales in Online

I'm getting almost the same error on a script that worked this morning. In my case it is "The remote server returned an error: (400) Bad Request". The code used it the same as Sverres example.

I'm guessing there are some network issues in Online.

Av: Frode Lillerud 1. sep 2017

RE: CRMScript now available for Sales in Online

So the event is happening, but it's not able to execute the CRMScript/code in CS by the looks of it.

Things should be running on the same site these days though, so I'm not sure why it would fail. Maybe Sverre turns up and can give some insight :) 

Av: Hans Wilhelmsen 1. sep 2017

Example that will be appreciated by Sales People!! 🌟

Hi,

Just got my hands on this great stuff, and created something all sales people would like to have :)

It's a small eventhandler on Event: Sales: After save document

Basically, it creates a followup appointment after creating an offer (documenttype 52)

 

Enjoy it, and have a nice weekend! 

 

#setLanguageLevel 3;

EventData ed = getEventData();
String header=ed.getInputValue("DocumentEntity.Header");

String doctype=ed.getInputValue("DocumentEntity.DocumentTemplate.DocumentTemplateId");

if (doctype=="52") //offer
{
        Integer contactid=ed.getInputValue("DocumentEntity.Contact.ContactId").toInteger();


        NSAppointmentAgent appAgent;
        NSAppointmentEntity newApp = appAgent.CreateDefaultAppointmentEntity();
        newApp.SetDescription("Nabellen Offerte");

        NSContact contact;
        contact.SetContactId(contactid);
        newApp.SetContact(contact);

          DateTime start;
          DateTime end;
          start.addDay(1);
          end = start.addMin(30);
          end = end.addHour(1);
          newApp.SetActiveDate(start);
          newApp.SetStartDate(start);
          newApp.SetEndDate(end);

          NSTaskListItem task;
          Integer taskId = 5; //"Follow-up";
          task.SetTaskListItemId(taskId);
          newApp.SetTask(task);

          NSAppointmentEntity createdApp;
          createdApp = appAgent.SaveAppointmentEntity(newApp);

}
Av: Niels van Broekhoven 1. sep 2017

RE: CRMScript now available for Sales in Online

Yeehah!! Niels is the best!!

Av: Joost van den Bogert 1. sep 2017

RE: CRMScript now available for Sales in Online

Hi there - just created my first event handler in 8.1 on premise - was wondering if AppointmentEntity.completed has been added in online since Sverre replied to Frodes comment?

Otherwise, really looking forward to follow the development of this awesome new function.

Thanks :)

Av: Dennis Aagaard Mortensgaard 7. nov 2017