Making variable editor editable based on state to opened by user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 08:04 PM
I want variable editor editable for CSM module in portal by "opened by" user in "draft" state.
When I create case via RP , after submit, it create case in "draft" state.
I want every variables to be shown and editable in portal for user. currently only comments is visible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:32 PM
I have added but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:36 PM
Ideally we should not allow end users to edit variables post submission, reason being the flow or workflow associated to it will trigger as soon as RITM is created and might cause issue if you are using the variable in any script
Remember this is an OOB widget and changes you do to this will be impacting every place
Ensure if you update then it happens only for your table records and not for other records
Something like this but please enhance it
Client Controller
(function() {
function isDraftState() {
return $scope.data.table === 'sn_customerservice_case' && $scope.data.recordState === 'draft';
}
$scope.canEditVariables = function() {
return isDraftState();
};
})();
Server Script:
(function() {
data.table = $sp.getParameter('table') || 'sn_customerservice_case';
data.sys_id = $sp.getParameter('sys_id');
data.recordState = getRecordState(data.table, data.sys_id);
function getRecordState(table, sys_id) {
var gr = new GlideRecord(table);
if (gr.get(sys_id)) {
return gr.state.toString();
}
return '';
}
})();
HTML:
<div ng-if="canEditVariables()">
<!-- Existing variable editor code -->
</div>
<div ng-if="!canEditVariables()">
<p>You can only edit variables in the Draft state.</p>
</div>
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 10:40 PM
not working, now it is not showing the variable editor in any state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:42 PM
what debugging did you perform?
I already informed the script needs to be enhanced
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader