- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 12:58 AM
When RITM is in 'waiting_for_approval' state, I need to hide new and edit button, Am writing below script, Which is resulting in hiding buttons in all state.
I tried using parent.stage='waiting_for_approval' and parent.stage=='waiting_for_approval'.
please suggest me what am doing wrong?
script:
----------------
var answer;
if((parent.assigned_to!=gs.getUserID()) || (!parent.active)||(parent.stage='waiting_for_approval')){
answer=true;
}
else{
answer=false;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 01:31 AM
OK. Please update your code as below:
Script:
if(parent.stage=='waiting_for_approval')
{
answer=true;
}
else if(parent.stage!='waiting_for_approval' && parent.assigned_to==gs.getUserID())
{
answer=true;
}
It's working for me on my Personal instance.Please find the scenarios I have tested as per your requirement.
Scenario 1: When the Stage of RITM is Waiting For Approval irrespective of Assigned To, the New button is made hidden irrespective of Assigned To. Please see the screen shot below:
Scenario 2: When the Stage is Not Waiting For Approval and say any other stage and now we are checking if the Assigned to User is same as Logged in User or not. If they are same we are again hiding the New Button. Please see the screenshot below:
I have logged in as System Administrator which is same as Assigned To so the New button is now not visible.
Scenario 3: Now when the stage is anything except Waiting for Approval and Assigned To is also not same as Logged in User which is your Third scenario so the New button would again be visible as shown below:
In the above screen shot I have again logged in as System Administrator and Assigned To is Abel Tuter, so now the New Button is visible.
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:22 AM
Hi looking at the code i think you need to update to below:
var answer;
if((parent.assigned_to!=gs.getUserID()) || (!parent.active)||(parent.stage=='waiting_for_approval')){
answer=true;
}
else{
answer=false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:28 AM
Hi,
You need to simply update your Code as mentioned below:
answer = ((parent.stage =='waiting_for_approval'));
For example On the Requested Item form, we have a Catalog Task Related List on which I am hiding the New buton if the stage is Waiting for Approval for all the Users including Admin Users as per the above code. Right click on the Catalog Task Related List header and select List Control and then write the above code in the field "Omit New Condition" as shown below:
Similarly you can write the same code in the field "Omit Edit Button" for removing the Edit button from the Related LIst.
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 04:51 AM
But Sholke,
I want to include all three conditions
if((parent.assigned_to!=gs.getUserID()) || (!parent.active)||(parent.stage='waiting_for_approval'))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 05:05 AM
You are missing a Equal to Operator in your statement while checking the stage Value. Single Equals means assigning and we need to check here so replace it with double Equal sign and use the below code :
if(parent.assigned_to!=gs.getUserID()|| (!parent.active)||(parent.stage=='waiting_for_approval'))
{
answer=false;
}
else
{
answer=true;
}
Regards,
Shloke
Regards,
Shloke