Loading...
Loading...
A glidefunction with a substring function may return a "General Data Exception detected by database (ERROR: negative substring length not allowed)" error if the arguments are negative. The arguments may be negative if you are using the position function to find the location of a string within another string, but that string does not exist, and you are also performing some maths on that position value (eg., subtracting some positions from it). For example: glidefunction:substring(description, '3', subtract(position('XYZ',description),'3')) If the "position('XYZ',description)" function above doesn't find the string XYZ in the description field, then it will return 0. Then the subtract function reduces it by 3 to give -3, which is a bad input. MySQL / Samurai databases ignored the bad input. RaptorDB is very strict and issues the error. Steps to Reproduce 1) Login to an instance with a RaptorDB backend. 2) Navigate to the All > System Definition > Dictionary module. 3) Click on the New button. 4) Click on the Advanced View related link. 5) Enter the following information: Table: incident Type: String Column label: Extracted Value Column name: u_extracted_value Max length: 40 Function field: True Function definition: glidefunction:substring(description, '6', subtract(position('Subject',description),'6')) 6) Click on the Update button. 7) Navigate to the Incident > All module. 8) Add the "Extracted Value" field to the list. Expected behaviour: The list should render. Actual behavior: The list shows "(empty)" values and a "General Data Exception detected by database (ERROR: negative substring length not allowed)" error
We are working on a fix for that issue. Click the button in the upper right of this article to subscribe and receive updates on this known error. Meanwhile the below workaround can be applied: Use the greatest() function to wrap around any function that could return a negative number. For example: glidefunction:substring(description, '3', greatest( subtract(position('XYZ',description),'3') , 0) FAQ: Q: How do I know where to apply the workaround? A: Candidate function fields to review can be found with the following filter: https://instancename.service-now.com/now/nav/ui/classic/params/target/sys_dictionary_list.do%3Fsysparm_query%3Dfunction_field%253Dtrue%255Efunction_definitionLIKEsubstring%255Efunction_definitionLIKEsubtract%26sysparm_first_row%3D1%26sysparm_view%3D This will return any function field which has both substring and subtract and the definition would have to be reviewed to determine if the third argument to any substring() function has the potential to result in a negative value, and therefore would need the workaround using greatest() applying to it. Q: Can I apply the workaround before being on Raptor DB? A: Yes. The workaround can be applied immediately without impact.
PRB1857656
Click on a version to see all relevant bugs
ServiceNow Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.