- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 08:58 AM
I have a records created through a catalog item, and want the variables following record creation to be readonly. I created a client script on table sc_req_item with simply alert('click') with no conditions. The client script only produces the alert when I click "New" for table sc_req_item, not when I load an existing sc_req_item with a variables pool populated. How do I get these to execute on existing records?
Onload client scripts against table sc_req_item:
function onLoad() {
alert('click'); //runs only on new item.
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 09:22 AM
William,
Look at your client script; you should see some checkboxes toward the top. Ensure that "Applies on Requested Items" is checked. This should solve your problem.
However,
I would use UI policies to do what you're attempting. Just create a UI policy with "Applies on Catalog Items" unchecked, and "Applies on Requested items" checked, and then create a UI Policy Action for each variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 09:41 AM
I can see that, if client scripting is the default in your organization.
I would encourage you to switch toward using UI policies whenever possible though; unless you use scripting, you don't have to do anything to get them ready for use with the new ServicePortal module.
However, with Client scripts, there's a whole host of things you have to check for, and you have to modify every single one (whether they contain the items you checked for or not) in order for them to apply to the ServicePortal page.
[Edit:] AND, you don't have to worry about some part of the client API that you used getting renamed or deprecated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 09:48 AM
Not sure how this will impact a client script on sc_req_item table!!?? What you are talking is a client script on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 09:52 AM
1st, I created a catalog client script on the catalog item assocaited with table sc_req_item. After checking the box "Applies on Catalog Items" a script works every time as expected following record creation.
2nd, I created a client script on table sc_req_item which simply places an alert stating it fired. That does not fire one the sc_req_item is created, if generated through a catalog item, which is not what I expected to happen.
While I can get what I need done with option(1) I expect the client script in option (2) to fire unconditionally following record creation and it does not. Wondering why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:01 AM
What kind of client script is #2?
In general, I can tell you that client scripts generally only fire when you're looking at a record (and in some cases, the table) for the relevant table. You can't, for example, write a client script that fires an alert any time an incident is created, and expect that alert to pop up no matter what else you are doing.
Regular client scripts aren't loaded unless you're looking at a record for the table in question. What you're describing is more how a Script action would work. You could, for example, write a UI action that was associated with an event you created (say, ritm.inserted) that would then fire an alert.
What is your use case for script #2?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2016 10:13 AM