- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2025 10:53 AM
Given: Demand record is created.
When: Demand team accesses the demand record
Then: Demand team should be able to mark Demand as cancel using Cancel Ul action button
AND
A pop-up should appear with Justification text box as manadatory field
AND
the pop-up content should be updated in the worknotes
Notes for Developers: Create Cancel Ul action button to cancel the Demand, on-clicck of which create one pop-up under which create
follwing fields:
1. Justification(mandatory field): A text field
2. Create 2 button as:
a. Submit
b. Close any one pls help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2025 10:34 AM
Hi @sakila - There are a number of things I'd do differently here, but you can improve your solution by moving your cancelDemand function into the UI action (in which case you don't need the script include at all).
UI Page [Name = cancel_demand]
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:ui_form>
        <p>Please add comments to close the demand:</p>
        <textarea id="justification_notes" rows="5" cols="50"></textarea>
        <div style="text-align: right; margin-top: 10px;">
            <g:dialog_buttons_ok_cancel ok_style_class="btn btn-primary" ok_text="${gs.getMessage('Submit')}" ok_type="button" cancel_type="button" />
        </div>
    </g:ui_form>
</j:jelly>Client script
function actionOK() {
	g_form.checkMandatory = false; // Ignore mandatory fields
	g_form.setValue('work_notes', gel('justification_notes').value.trim());
	gsftSubmit(null, g_form.getFormElement(), 'cancel_demand');
}
UI Action [Action name = cancel_demand]
Script
function showModal(){
	modal = new GlideModal('cancel_demand');
	modal.setTitle('Confirm Action');
	modal.setWidth('400');
	modal.render();
}
if (typeof window == "undefined") {
	cancelDemand();
}
function cancelDemand() {
	var table = current.getTableName();
	var cdv = current.getClassDisplayValue();
	current.state = '11'; // Cancelled
	gs.addInfoMessage(cdv + ' <a href="/' + table + '.do?sys_id=' + current.sys_id + '">' + current.number + '</a> has been cancelled.');
	current.update();
	action.setRedirectURL(current);
}
You’ll notice I’ve set the state to 11 rather than 7. By default, 7 corresponds to "Rejected" and you may want to distinguish between "Cancelled" and "Rejected". Keep in mind that state 7 is mapped to a demand stage in dmn_stage_config, and in the flow formatter it will appear as "Deferred" unless you update the records in sys_process_flow, so the choice matters. In my view, distinguishing "Cancelled" from "Rejected" is worth the small extra effort to keep the meanings clear.
Additionally, you'll want to set the appropriate conditions on the UI action. For example:
!current.isNewRecord() && gs.hasRole(DemandUtil.getDemandRole('manager',current.getTableName())) && (current.state != 9 && current.state != 11) && current.project.nil()
Finally, don't forget to update the UI Page so the justification field is mandatory per your requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2025 09:51 PM
any one help here . i written code ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2025 10:34 AM
Hi @sakila - There are a number of things I'd do differently here, but you can improve your solution by moving your cancelDemand function into the UI action (in which case you don't need the script include at all).
UI Page [Name = cancel_demand]
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:ui_form>
        <p>Please add comments to close the demand:</p>
        <textarea id="justification_notes" rows="5" cols="50"></textarea>
        <div style="text-align: right; margin-top: 10px;">
            <g:dialog_buttons_ok_cancel ok_style_class="btn btn-primary" ok_text="${gs.getMessage('Submit')}" ok_type="button" cancel_type="button" />
        </div>
    </g:ui_form>
</j:jelly>Client script
function actionOK() {
	g_form.checkMandatory = false; // Ignore mandatory fields
	g_form.setValue('work_notes', gel('justification_notes').value.trim());
	gsftSubmit(null, g_form.getFormElement(), 'cancel_demand');
}
UI Action [Action name = cancel_demand]
Script
function showModal(){
	modal = new GlideModal('cancel_demand');
	modal.setTitle('Confirm Action');
	modal.setWidth('400');
	modal.render();
}
if (typeof window == "undefined") {
	cancelDemand();
}
function cancelDemand() {
	var table = current.getTableName();
	var cdv = current.getClassDisplayValue();
	current.state = '11'; // Cancelled
	gs.addInfoMessage(cdv + ' <a href="/' + table + '.do?sys_id=' + current.sys_id + '">' + current.number + '</a> has been cancelled.');
	current.update();
	action.setRedirectURL(current);
}
You’ll notice I’ve set the state to 11 rather than 7. By default, 7 corresponds to "Rejected" and you may want to distinguish between "Cancelled" and "Rejected". Keep in mind that state 7 is mapped to a demand stage in dmn_stage_config, and in the flow formatter it will appear as "Deferred" unless you update the records in sys_process_flow, so the choice matters. In my view, distinguishing "Cancelled" from "Rejected" is worth the small extra effort to keep the meanings clear.
Additionally, you'll want to set the appropriate conditions on the UI action. For example:
!current.isNewRecord() && gs.hasRole(DemandUtil.getDemandRole('manager',current.getTableName())) && (current.state != 9 && current.state != 11) && current.project.nil()
Finally, don't forget to update the UI Page so the justification field is mandatory per your requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2025 08:09 AM
I will try and let you know. Thanks for reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2025 09:23 AM
instead of am trying this one just i tried
