- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2019 02:25 PM
Need to show 'Add' button only for few states. Currently this Add button on Affected CIs is visible when state is draft, I need to show this for few other states.
This is the condition mentioned in the UI action - RP.isManyToMany() && (new ChangeProposed(parent)).canAddCI() && current.canCreate() && parent.active == true && gs.getProperty('com.snc.task.associate_ci').indexOf(parent.sys_class_name) > -1
I tried adding current.state==-4 etc but that didn't work. Am I missing something?
Solved! Go to Solution.
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2019 02:12 PM
Most out of the box scripts are marked as SNC at the end of them, and typically there will be a non-SNC version that allows you to extend that script, and "add" to it, or "overwrite" existing functions/variables.
Since you all have altered the OOB Change States, I'm assuming you've also had to alter the State Handler script (ChangeRequestStateHandler which is the extended version of ChangeRequestStateHandlerSNC) in order to allow for the Change to move from State to State.
So I think the correct way to handle this would be to add the new States to the ChangeRequestStateHandler Script Include.
Then create new functions for those states in the ChangeRequest script include that are modeled after the existing isSTATE() functions in the ChangeRequestSNC script include.
Then you can use those functions in the ChangeProposed script include if statement condition.
ORRRRR....
I think there may be a quick and dirty way to do it. BUT, it comes with a disclaimer. I'll have to say I don't recommend this, and I don't know if it will break any other functionality. I'll let you decide.
Instead of using the other APIs to check the state, use the GlideRecord object in the ChangeProposed script (this._grChgReq). This way you could input the states as you like with their back-end values. I don't know the back-end values for all of your custom states, but they should be numeric. Here's an example, -5 is the backend value for New and -2 is Scheduled. Add to this:
canAddCI: function() {
// If it's not a change task, return true and let other conditions decide
// This has to be done as the Add CI action could be used on all types of tasks
if (!this._isChangeTask)
return true;
// If it's a change in the new state, return allow adding of CIs
// 2019-10-30 -- Customizing to allow additonal Change states to add CIs
if (this._grChgReq.state == '-5' || this._grChgReq.state == '-2'))
return true;
if (this._log.atLevel(GSLog.DEBUG))
this._log.debug("[canAddCI] Cannot add CIs to Change Request " + this._grChgReq.number + ":" + this._grChgReq.getUniqueValue());
// In all other cases, don't allow addition of CIs
return false;
},
If my answer helped you, or solved your issue, please help me out by marking it as Helpful or Correct!
Thanks,
Josh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 09:56 AM
Hi Chris,
I followed the instructions but im having the same issue. Have you find a solution for this?
Hi guys need your help
Your response will be much appreciated. Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2019 03:18 PM
Yes, thanks Josh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2020 11:17 AM
Hi Archie,
How did you manage to make this work? I followed the instructions given by
Your help will be much appreciated, Thanks in advance!