simulate Reference Quaifier onSubmit

KeDix
Tera Guru

I have a few fields with Reference Qualifier attached to them. Due to templates, users have some invalid values stored in them. I want to make sure that data is saved with only valid values.

 

How can it be done to simulate the ref qual on those fields before submit/save?

4 ACCEPTED SOLUTIONS

sonam927neg
Giga Contributor

Hello,

 

Use the onChange or onSubmit functions to send the field's current value to the server. Contains a function that takes the value and the Reference Qualifier string, and returns true or false indicating if the value is valid based on the qualifier.

View solution in original post

Brad Bowman
Kilo Patron

You'll have to call a Script Include via GlideAjax in an onSubmit Client Script, passing in the value of each field that needs checked.  The Script Include needs to be coded in such a way as to check the reference table for each field against the criteria in each reference qualifier, returning a message or certain value if any are invalid, then the Client Script can abort the submit if that value is returned.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

View solution in original post

@KeDix 

then in script of business rule you need to hard-code the filter condition or logic for those fields configured in dictionary level and then handle that.

that's the only way

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

KeDix
Tera Guru

I have used the OnUpdate Business Rule and used the same reference qualifiers that are there on the field(s). In addition, I have passed the selected value (text/sys_id) to check if it is part of the values returned by Ref Qual 

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@KeDix 

share some screenshots.

you can use before insert/update business rule and validate the values in those reference fields satisfy the ref qualifier or not

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Ankur Bawiskar

I won't be able to use ref qual as it is in Business Rule. I want to use the same logic, but do not want to repeat it as it may change in the future. Some Ref Qual are directly on the field, while some use Script Include.

@KeDix 

then in script of business rule you need to hard-code the filter condition or logic for those fields configured in dictionary level and then handle that.

that's the only way

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

sonam927neg
Giga Contributor

Hello,

 

Use the onChange or onSubmit functions to send the field's current value to the server. Contains a function that takes the value and the Reference Qualifier string, and returns true or false indicating if the value is valid based on the qualifier.