Run/Call a UI in Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2013 03:05 PM
I need to know how to run the UI Action(Refresh Impacted Services) when the value for the Configuration item field on the Change Request form changes.
I was told I need to create a Business Rule. Here is the if condition:
// check to see the CI field has changed
if(current.cmdb_ci.changes())
run UI action named "Refresh Impacted Services" - this is what i need the proper script for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2013 07:36 PM
I'm assuming you are trying to keep that Related List updated automatically whenever the CI changes. The safest way to do it would be to create a new After Insert/Update Business Rule like you said and copy/paste the code from the UI Action into the BR minus the first 2 lines and use your "current.cmdb_ci.changes()" as the condition.
If you wanted to customize what the function was actually doing, you might consider creating a Script Include that gets called from the Business Rule and the UI Action so you have to maintain it in only 1 place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2013 06:35 AM
Great thanks Jim i'll give that a shot. But just for the record- is there anyway to call a ui action in a script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2013 07:18 AM
Yes, and no 🙂
You can call a UI Action from a Client Script because they are both running on the browser (technically the UI Action code runs on the server, but it is fired from the client). You can do that with the following call:
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
where "sysverb_update_and_stay" is the "Action name" of the UI Action (in this case, the "Save" button).
You can't call a UI Action from a server script (Business Rule, Script Include, etc...) because they are running in different contexts, one on the server and the other in the browser. Now someone might come up with a way to do it, but for me, it really would not make much sense as you need to separate the 2 layers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2013 10:07 AM
Ok thanks Jim, yea I guess I was a little confused about the fact that the ui action is considered more client-side (even though it runs on the server) and a business rule strictly server-side. this clears things up.