client script on dot walk fields?

jerryzhou
Kilo Explorer

Hi,

  Is there a way to run a client script   against a dot walk fields? I have a client script to check the format of requiter's phone number. It works well when user change phone number from the requester form.

            But , this field is dot walked into the main case form via the requester reference field, when user change the phone number from the main case from,   it goes through to the requester record without check the format, I try to get the client script on the main case form, but could not find the field (no dot walk from the field list for client script)

  could some suggest a way to check the phone format on the dot walked field? Or I missed something?

Thanks!

Jerry

8 REPLIES 8

Hi Jerry,



Not sure on web object but onChange client script not possible on dotwalking field. Let's wait if some expert assist us with some different ideas.


shloke04
Kilo Patron

Hi,



What you can do is Create a Display Business Rule on the Required Table and store the Dot walking Value required in a Scratchpad Variable. Now you can pass the Dot walk field Value from Business Rule to Client Script and have the Validation as required on the Client Side.



You can refer the below link point Number 7 on how to configure and Use Scratchpad Variable on Client Side:



http://wiki.servicenow.com/index.php?title=Scripting_in_Business_Rules#Scripting_with_Display_Busine...



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shioke,


  Not sure 100 % understand what you suggested, our purpose is to check the format of the phone number, not a predefined value, to check that I have client script with some kind of regular expression to check against on the requester for, do you think the display business rule and the scratchpad can be used   for this on   the main case table?




Thanks!



Jerry


Joe72
Tera Contributor

Hey Jerry,

I know this is an old request, but this business need just came up for me as well. There is no good way of doing this OOB. You can use a UI Policy, but that would only capture the first change made to the dot-walked field. If you saved the record after each edit, that could be an OOB solution, but saving after a field edit isn't great UIX.

The other way of doing this is to create your own listener using jQuery:

//This may not work for certain field types (i.e. reference fields)
jQuery(g_form.getControl('name_of.dot_walked_field_here')).change(function() {
   var value = this.value;
   console.log(value);
   //Do Validation Here
});

As this is a DOM solution, it may stop working if ServiceNow changes their UI structure.