Modify com.glideapp.servicecatalog_checkout_view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2012 10:55 AM
I was trying to modify the UI Page 'com.glideapp.servicecatalog_checkout_view'.
I am trying to add 'state' field which changes based on the 'stage' field from Workflow on the ticket. I am able to retrieve the value coming from the 'stage' field. But when I am trying to write an IF statement and comparing to the value, it is not working. It is in Jelly Scripting. Can anyone help be in the debug?
SEE THE SCREENSHOT BELOW
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2012 12:56 PM
I added the UI page but.. the problem is when there are 2 RITMs under the same REQ. So please try adding one more item to the art and see that the SCTSK generated for both RITMs is the same number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2012 03:01 PM
So you want to show just the tasks for that particular RITM record? If so, take a look at demo11 now.
The if statement changes to:
<j2:if test="$[sc_req_item.stage == 'Procure Blackberry Hardware']">
Click for Status<button onclick="test_button('$[sc_req_item.sys_id]')" id="status.$[sc_req_item.number]" name="status.$[sc_req_item.number]" value="$[sc_req_item.number]"
style="background-color: white; border: none"><img src="image.jpgx" width="l8" height="l8"/></button>
</j2:if>
Notice how I added the sys_id of the RITM right in the onclick function. We already know it, so no point search for it later (which I think was the problem you were having, it was just finding the first item).
The function added to the bottom of the "com.glideapp.servicecatalog_checkout_view" UI Page changes to:
function test_button(item){
var dialog = new GlideDialogWindow('test');
dialog.setTitle('Catalog tasks'); //Set the dialog title
dialog.setSize(1000,1000); //Set the dialog size
dialog.setPreference("sysparm_ritm_id", item);
dialog.render(); //Open the dialog
}
And then the "test" UI Page is:
<?xml version="1.0" encoding="utf-8"?>
Task Number | State |
---|---|
$[sc_task.number.getDisplayValue()] | $[sc_task.state.getDisplayValue()] |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2012 03:29 PM
It worked Jim. Thanksa lto but I wanted to know why is this working and why not the thing I wrote. As I was also trying to get the 'item' value in the test_button() function and passing that in setPreference().
And also I see you modified the test dialogue, the whole RITM loop, can you plx elaborate that. And what is 'sysparm_ritm_id'
Thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2012 05:13 PM
My understanding is that, with onClick('$[sc_req_item.sys_id]'), we are passing the sys_id of the RITM, which ispassed into the funciton.
Then we set the 'sysparm_ritm_id' variable the values of the RITM sys_id using Setpreference method, which is retrieved int he UI page and compared witht he RITM.
My question is where did I go wrong.
Thanks Jim again for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2012 08:38 PM
I added the sys_id of the RITM record right into the onclick function because at that point we already know what it is so it is better to include it then instead of searching the DOM for it later in the test_button() function. Plus, the "gel("status.$[sc_req_item.number]").value;" bit in the function would have always evaluated to "status."+ number of the last RITM on the request, so that would not have worked for multiple items on an order.
Like you said, the sys_id of the item is sent as a parameter using setPreference and then retrieved in the UI Page for the query parameter.
I remove the GlideRecord variable you created on the sc_req_item table because that was not needed as you wanted the tasks and we had the sys_id of the RITM already.
I think there was an issue with which phase certain things were being done in as well. You have to use [] inside the g2 and j2 tags and {} in the g and j tags. Jelly can be pretty weird to work with - I keep having to go back to SlightlyLooney's blog posts for a refresher.