- 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-27-2015 10:42 PM
In addition to creating the record in Identity Management Platform you should also keep the same record in Snow. It will help you in case of any data discrepancies or errors. I will suggest to create a Table for this having all these mentioned fields and then from a business rule call the script include (Server Side) . Also you could create additional fields status on the same table and this filed could be used for Error logging purposes. You could populate this field with Success/Failure value corresponding to each record which is nothing but the response of the Soap Call for the corresponding record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 09:40 AM
Hi Gurpreet
Thanks for those very valid points.
I'd like to get something working and then i'll look a bit more closely at logs and error checking.
Ive had a look atJohn Andersen's site, ServiceNow Integrations Overview Video-John Andersen, which would suggest its possible to use a business rule on its own and push details straight into IDM. My issue with that approach is i can't grab the data from the fields to push through to soap post. For e.g the middle name on the field might be something like 'mitchell' but the record gets created in IDM with middle name as 'current.u_middle_name'
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();
Any suggestions on correcting this behavior?
- 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 04:34 PM
Hi John
It was a pleasant surprise to have your comment.
Thanks, the quotes were removed and data pulled into SOAP message very well. Getting this working has helped me since to developed 2 ways of posting the soap message.
i found using business rule for this was very quick in terms of performance to grab form details and post to IDM.
However to bring things in line with existing scripts i managed to get UI Action calling SI since it already had all the error loging and messages to user included in the SI script, and as was commented earlier by Chris Nanda, this does impact performance. If i can work out the error logging and success message to the end-user on the ASYNC business rule approach, i probably go with that instead, as Chris Nanda has suggested. Any help on scripting this message to appear to user after business rule has run and SOAP message successfully posted to IDM platform would be appreciated. Although they do not need to see the user record they just created, they do need to know that the process completed successfully and then return to a home page url after 5 seconds of being displayed.
To your point Julian, unfortunately i have to use a mid server as the user is being created on a 3rd party platform.