- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 03:36 AM
Hi Guys,
I have written a List banner buttons (approve/reject) to show up on related list based on related list record status.
I have written as (current.state==13) for showing up button when current record is approved and (current.state==5) when current records is rejected.
But when related list has combination of both approved and rejected records, the related list should contain both approve and reject buttons.
Please help me how to keep the COND statement for this scenario in list banner button.
Appreciate your help,
Naveen B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 02:43 AM
I do get it to work with passing the sys_id to the script include by using current.getUniqueValue()
Condition in UI Action
new testUtils().testFunction(current.getUniqueValue());
My Script Include
var testUtils = Class.create();
testUtils.prototype = {
initialize: function() {
},
testFunction: function(sysid) {
gs.log('TEST sys_id: ' + sysid);
var agg = new GlideAggregate('incident');
agg.addQuery('parent', sysid);
agg.addAggregate('COUNT');
agg.query();
var answer = 'false';
var count = '';
if (agg.next()) {
count = agg.getAggregate('COUNT');
if (count > 0)
answer = 'true';
else
answer = 'false';
}
gs.log('TEST count: ' + count);
gs.log('TEST answer: ' + answer);
return answer;
},
type: 'testUtils'
};
My button is being displayed/hidden depending on if there are any child incidents connected to an incident (using parent field)
Remember to check the checkbox Client Callable on the Script Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 05:41 AM
In the condition field you write the following
new scriptIncludeName().functionName()
This will call the Script Include you created and the function in the script include.
All the calculations is done in the function and it will return true or false. If it return true it will show the UI Action, if it returns false it will not show it.
You need to create the script include and add a function in the script include where you put the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 06:37 AM
ok thank you very much for the efforts Palmen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 04:20 AM
Hi Palmen,
Thank you for the ode u hv given, it is working. but our requirement is such that as shown in the belo screenshot
If the related list had the multiple records of with both Approved and Rejected status then it should show the "charges Applied" button for approved records, and "cancel" button for rejected records.
But as of now it is showing only one of the buttons..and it should shoe two buttons since we have both states
Please help me in this regards,
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 06:53 AM
You need to add the condition to booth the buttons.
But for the reject button you need to create another function (secondFunctionName()) in your script include and change the following row
agg.addQuery('state', '13');
Instead it should be
agg.addQuery('state', '5');
So for the reject button you change the conditon to be
new scriptIncludeName().secondFunctionName()
Please mark helpful if this helps you, or correct if it solves your requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 07:22 AM
Yes I did in the same way
I have created separate functions one for Approve(13) and another one for Reject(5)
and in both of them code goes like this
var agg = new GlideAggregate('x_tere_telstra_who_adjustment');
agg.addQuery('sys_id',current.sys_id);
agg.addQuery('state', '5'); // here we use 13 for approve function
agg.addAggregate('COUNT','state');
agg.query();
var answer = 'false';
if (agg.next()) {
answer = agg.getAggregate('COUNT');
if (answer > 0)
answer = 'true';
else
answer = 'false';
}
gs.info('intonewscrptInc CANCEL'+agg.getAggregate('COUNT'));
return answer;
please let me know where am doing it wrong, and I guess the count of approved or rejected records are not stored on every creation of new record.