Help with business rule calling webservices

pauladams
Tera Contributor

I have a SOAP based webservice that I am trying to call in a business rule. I've tested the SOAP message by configuring SOAP message parameters and it works perfectly fine.

The problem is I am unable to use the same SOAP message in a business rule to create incidents.

My requirement is as follows. Any incident created in one of my instances should be automatically created in the other instance.

I've created an inbound webservice on my destination instance, and an outbound SOAP message on my source instance.

I've used the "Preview script usage" from one of the SOAP message functions i.e. insert and modified the script in the business rule.

The business rule is configured as follows:

find_real_file.png

find_real_file.png

find_real_file.png

It doesn't work and when I look at the "Debug Output" it shows the below

find_real_file.png

Have been breaking my head very badly to understand what's going on with this. As part of debugging, I've disabled the "Advanced" option and used an action to update some fields which works fine. I tried with after too.

Where is it going wrong? Its a Eureka instance (please don't laugh )

4 REPLIES 4

amlanpal
Kilo Sage

Hi Paul,



If my understanding is not wrong, your requirement is to create the same incident on the Destination instance if the any incident is getting created in the source instance. As you have said you have already defined respective inbound and outbound webservices.


So please create/modify the Business rule in the source instance. The Business rule should run after insert and(or) update. And please don't forget to pass the proper variable attributes inside the Business rule like below:



// Here 'u_number1' is the variable attribute which you have defined inside the SOAP message function and number is field of the table.


s.setStringParameter('u_number1', current.number);



Also, I wonder, you can use create SOAP function to acheive this functionality.



I hope this helps.Please mark correct/helpful based on impact



Ankur Bawiskar
Tera Patron
Tera Patron

Hi Paul,



Can you add log statements in your business rule to check whether the business rule itself is getting executed or not?


The code seems fine to me except that this line i.e. update this line



var s = new SOAPMessage() // there should be space between new keyword and Class SOAPMessage()



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks Ankur Bawiskar bawiskar.


It worked!!!


However, I have new problem now. From the source I am passing the requestor and assigned to but at the destination it is showing the sys_id of caller and assigned to.


The same users exists on both the instances but their profiles are different i.e. email address, location etc. are different.


Do we need to have exact matching profiles of the users on both instances?


Hi Paul,



The profile needs to be same atleast the user_name


Also since you have defined your own web service. You must be having the field maps for the fields.


For the field map of user field, send username to the web service and in the field map you must be selecting the user field.


you will get something like this



transform-map.JPG



In the referenced value field name instead of name give user_name.


So what it does is compares the user_name which you sent with the one present in sys_user table. If found then it populates in the target field. if not it ignores.


If you don't give choice action as ignore it will create a user with the username you sent if not found in sys_user table



Also Can you please mark the answer as correct, helpful and hit like since you were able to achieve your requirement. Thanks in advance.




Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader