Referencing an onLoad function from a changing text field in Service Portal

andypollino
Mega Expert

Hi guys.

A while ago, I ran into a problem where I had a function that should run only once nine different fields all have a value. I didn't want to type it all up and make small changes because that would be difficult to maintain, so jim.coyne came to the rescue here: Multiple fields with onChange

He told the user that asked that they should define the function in an onLoad script and reference it from their onChange scripts. That solution worked for me! Today, I tried to introduce the Request Item that implemented this into our Service Portal, and I had some difficulty. When my text field (txtCustomCPU) changes, my browser will run the onChange script, but the onChange script references a function (setPrices) defined in the onLoad. I believe my onLoad ran properly because the actual onLoad functionality worked, but I believe that setPrices is not being called at all. I replicated this in my personal developer instance with a simple alert in the onLoad and a call to that alert in the onChange. Like in my environment, the personal instance worked in the native UI but failed to work in the Service Portal. There was other, also weird behavior for check boxes, but all the fields in question are Single Line Text.

I'm on Istanbul. Any thoughts?

1 ACCEPTED SOLUTION

This type of behavior is working fine in desktop or native Ui but in service portal its not working.


Basically in native UI if you call any function on the form, that will be available to all the client scripts. But same thing was not rendering in service portal.



So if you want to make it run in service portal also, you need to copy and paste the script in onChange client script also.



or one more way was you can write a UI Scripts in service portal, but there are 2 disadvantages, Service Portal UI Script or Reusable functions in Client Scripts


1) Ui scripts may lead to performance issues, because ui scripts will load on global form also.


2)In chrome browsers may lead some cache issues, Some time if you edit the code also it behaves old functionality. But in IE its working perfectly (This is based on my testing results).


View solution in original post

6 REPLIES 6

This type of behavior is working fine in desktop or native Ui but in service portal its not working.


Basically in native UI if you call any function on the form, that will be available to all the client scripts. But same thing was not rendering in service portal.



So if you want to make it run in service portal also, you need to copy and paste the script in onChange client script also.



or one more way was you can write a UI Scripts in service portal, but there are 2 disadvantages, Service Portal UI Script or Reusable functions in Client Scripts


1) Ui scripts may lead to performance issues, because ui scripts will load on global form also.


2)In chrome browsers may lead some cache issues, Some time if you edit the code also it behaves old functionality. But in IE its working perfectly (This is based on my testing results).


Let me know if that answered your question. If so, please mark the response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you


How To Mark Answers Correct From Community Inbox