html field not passing data across via api

CandyDee
Kilo Sage

Afternoon all

 

Im working on an ServiceNow to ServiceNow integration via Rest API.

 

I have a field 'implementation plan' on my side which is a string field. On the Customers side the 'Implementation Plan' field is a HTML field.

 

When i create my record and send via rest api I can pass the text i type into my 'Implementation plan' field  and it appears as it should on there side. So all good.

 

When the customer creates a record on there side to send across , What they type into there Implementation plan field  doesn't come across, It arrives with 'Undefined' i think. I'm guessing there is a json method i may have to use.

 

Any suggestions or anyone had the same issue and got a solution. Thanks all. 

1 ACCEPTED SOLUTION

@CandyDee As implementation plan is a html field it return the html string not the object. So instead of passing it to jsonEncode function. use the script below to extract text from html string.

 

var implementationPlan = current.implementation_plan+'';
implementationPlan = implementationPlan.replace(/<\/?[^>]+(>|$)/g, "");
//Send this in the API setStringParameter function

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

4 REPLIES 4

jaheerhattiwale
Mega Sage
Mega Sage

@CandyDee Its should pass as the HTML field return the HTML in string format itself.

 

Can you please add the screenshots of the code where you are facing issue?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi Jaheer thanks for the response. The below is the business rule with the code, all other fields are working fine. 

 

 

@CandyDee Can you please post the jsonEncode function as well?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@CandyDee As implementation plan is a html field it return the html string not the object. So instead of passing it to jsonEncode function. use the script below to extract text from html string.

 

var implementationPlan = current.implementation_plan+'';
implementationPlan = implementationPlan.replace(/<\/?[^>]+(>|$)/g, "");
//Send this in the API setStringParameter function

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023