- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 08:41 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 01:07 PM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 09:00 AM
Can you verify that the UI Type on the scripts is "Both" and if not change it to Both and test it again?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 09:06 AM
Both is not an option for me, but all scripts have a UI Type of "All," and it does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 11:14 AM
can you post both your scripts ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2017 12:55 PM
Sorry for the huge delay! Here are my scripts in my personal developer instance (which also doesn't work, as mentioned above):
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
alert('going to call mpe');
mpe();
}
function onLoad() {
//Type appropriate comment here, and begin script below
}
function mpe() {
alert('mpe');
}
If this pairing of scripts worked and I got the popup box that says "mpe," I would be confident in being able to figure out how to work in my personal instance!