- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2015 04:23 PM
Sending data from SN to an Identity Management Platform via SOAP
SOAP Call from Service Now Forms to IDM Platforms
I have a challenge that has been frustrating me for weeks. It involves creating new starter employee records in a 3rd Party Identity Management Platform via a mid-server using SOAP calls.
What I've done so far:-
- I have developed a form with fields that capture 'first name' 'last name' (as strings) 'department', 'location' & 'employee' (UID's) details on a table for e.g. called u_starter.do (I'm using Eureka version).
- I've managed to create background script that works well and creates the users on the IDM side. However this method requires manual input of data to the script variables. I've posted this below for reference.
var s = new SOAPMessage('IDM Test', 'AESPMLServiceSoap.addRequest');
s.setStringParameter('las_name', 'test9');
s.setStringParameter('new_dept', '5699bc13-a755-483c-a2b7-ea52c3e7da99');
s.setStringParameter('fir_name', 'test9');
s.setStringParameter('new_etype', '8f9a21cf-3acb-4100-9645-39cf8cb3ad99');
s.setStringParameter('new_loc', '37dd3a02-5892-474c-961e-787ad3fdba99');
var response = s.post();
var k = 1;
var r = s.getResponse();
while(r == null) {
gs.log("waiting ... " + k + " seconds");
r = s.getResponse(1000);
k++;
if (k > 30) {
break; // service did not respond after 30 tries
}
}
- gs.log(r);
- gs.log(s.getHttpHeader('Content-Type'));
THE GOAL:-
My goal is to simply to capture details from the starters form fields by using a UI Action button client-side and doing a Ajax call to a script include called 'example_functions'.
Then the script include would post the data input received from client to ID manager via a soap call.
When successful I'm going to try and notify the client and give them read only view of what they entered. There's an existing Script done by our implementer s, some years back which is an script include that does what I'd also like my function to do, but I can't fathom out how to utilize or copy it. I've included a section of it as, an attachment.
I'd appreciate knowing if this is the best way to achieve my goal. Also as my scripting skills a very limited I'd appreciate any help with creating the UI script and the SI script especially.
1). UI script send data client side to server side.
2). SI script receive data from client and post via mid server soap message to ID Manager.
3). Error logging and success result indication.
Solved! Go to Solution.
- Labels:
-
Integrations
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2015 09:50 AM
Hey Tony,
Remove the quotes around "current.u_middle_name". If that is a variable, it shouldn't be quoted. Without the quotes, the value of the variable will be passed into that for you.
example:
var s = new SOAPMessage('IDM Test', 'AESPMLServiceSoap.addRequest');
s.setStringParameter('mid_name', current.u_middle_name);
s.setStringParameter('las_name', current.u_last_name);
s.setStringParameter('new_dept', current.u_department);
s.setStringParameter('new_mobile', current.u_personal_mobile_number);
s.setStringParameter('fir_name', current.u_first_name);
s.setStringParameter('new_etype', current.u_employee_type);
s.setStringParameter('new_loc', current.u_location);
var response = s.post();
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2015 09:44 PM
Hi Tony,
In business rule itself you could add a Message to be displayed to user.
var s = new SOAPMessage('IDM Test', 'AESPMLServiceSoap.addRequest');
s.setStringParameter('mid_name', current.u_middle_name);
s.setStringParameter('las_name', current.u_last_name);
s.setStringParameter('new_dept', current.u_department);
s.setStringParameter('new_mobile', current.u_personal_mobile_number);
s.setStringParameter('fir_name', current.u_first_name);
s.setStringParameter('new_etype', current.u_employee_type);
s.setStringParameter('new_loc', current.u_location);
var response = s.post();
gs.addInfoMessage("Message "+response) ; //Here type your own message
You may also need to parse the response depending on its format
Scripting Outbound SOAP - Versions Prior to Fuji - ServiceNow Wiki
Also in UI Action , you could specify redirectURL to redirect user to any other page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2015 11:50 AM
Thanks Gurpreet
I have a message to user working and appears at top of form window and not very eye-catching. However im using the current.update() at end of script and the form submits and stays inplace with the field still editable. This will no doubt confuse the user. Is there a way to use current.update() or security or something else that confirms the form has been submitted, but comes back with a READ ONLY version of that record for them to see what they've submitted? A kind of summary page is what i guess im looking for. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2015 10:08 PM
There is no need to use current.update() in business rule, Please avoid it.
Business Rules Best Practices - ServiceNow Wiki
You could use Write ACL to make fields Readonly after the record submitted.
Type: record
Operation: write
Name: table_name
Script: current.isNewRecord();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2015 02:31 AM
I use a combination of a Business Rule that calls a Script Include when using SOAP
However, we are not going via a MID server. We decided against this as we want to provide the user with immediate feedback on the status of the ticket when being passed to the 3rd party
The business rule determines if it needs run. It does some scripting that will determine a few messages and update the ticket with the remote system's reference, and then calls the script include
The script include creates the envelope, and passes the values over via the s.setStringParameter
The script include returns a value - either ticket ID or error
This is checked for any errors or issues, any that are found an error message is dsiplayed (gs.addErrorMessage)
If there are no errors, I retrieve the remote ticket id and then based on this being a new ticket or existing ticket on the remote site, inform the user of the new ticket id, or that the existing remote ticket was updated. (gs.addInfoMessage)
In the Script include I add logging so I can see the envelope that is being sent, and the response from the remote system
var s = new SOAPMessage('abc','insert')
s.setStringParameter('comments',current.comments);
<--- do work --->
var r = s.post();
gs.log('Sending the following SOAP : ' + s.evelope);
gs.log('Got WSDL response : ' + r);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2015 02:16 PM
Tony,
Just to be sure (and it sounds like you are), you are doing this via AJAX correct? I just notice you mentioned this is VIA a mid server, and if you do this via a synchronous approach (before or after business rule) then that may cause a very poor user experience.
Also, IF you are doing this via ajax, my question would be does the user really need to know about this? Meaning, is UI feedback of the completed request required, otherwise, an ASYNC business rule might be your best bet. Because a request through the mid server could take up to 30 seconds, depending on the configuration of your mid server, and even if you are doing this via AJAX, making the user wait for that feels like an eternity.