Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Why isn't URL field keeping the value set by BR?

russellj03
Giga Contributor


I have a URL field in a table that I want to be populated by an onBefore BR that parses a link from the description field.

After the parse and setting the field, I have a log statement that shows the field has the URL value I want, but when I open the record the URL field is blank.

When I manually edit the field (paste in the value), the value stays and works normally, so I know there isn't a problem with the field itself.   Is there something else I need to do after the "current.u_url = url;" line in the BR to make the value stick?

1 ACCEPTED SOLUTION

I figured out the problem, but first my apologies for doing a poor job describing the scenario.



My business rule was calling a script include, which is why the function was written that way, as you pointed out.   The other thing is that the data is coming in via a web service (u_incident), with a transform map transforming the data into the incident table.   But the business rule runs on u_incident, not incident.



The key issue was that when I was setting current.u_url, that was in u_incident, even though the field didn't exist there.   I don't know why I didn't get an error or undefined result when I logged the variable's value.   But once I created the url field in the web service and added it to the transform map, it worked fine with the script the way I originally had it.



Thanks for all of the help!


View solution in original post

8 REPLIES 8

Add the field in the list layout and see if the value is filled for the field .. This will confirm if the client script/ui policy are involved in this scam


The field in the list layout is also blank.


Just a few suggestions that may help in your issues if it turns out to not be UI Policies or Client Scripts getting in the way:




I would rewrite your populateURLField function like this:




function populateURLField() {


...


}



I've only seen


populateURLField : function()

written in classes and script includes.




current.description

is an object type and the .match() function is for string.


I wouldn't depend on javascript to coerce it for me in this case, and would write it as:


current.description.toString().match(urlRegex);

I figured out the problem, but first my apologies for doing a poor job describing the scenario.



My business rule was calling a script include, which is why the function was written that way, as you pointed out.   The other thing is that the data is coming in via a web service (u_incident), with a transform map transforming the data into the incident table.   But the business rule runs on u_incident, not incident.



The key issue was that when I was setting current.u_url, that was in u_incident, even though the field didn't exist there.   I don't know why I didn't get an error or undefined result when I logged the variable's value.   But once I created the url field in the web service and added it to the transform map, it worked fine with the script the way I originally had it.



Thanks for all of the help!