Create Demand on Idea acceptance. BR is working fine except for one field not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:06 AM
Hi,
I have a BR in place that creates demand when Idea is being accepted. That code is not written by me but someone who was their earlier.
I have added two lines of code. That should populate Portfolio on Idea form to Portfolio on demand form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2024 03:31 PM
Hi @Vaishnavi35 ,
I have worked on some similar issues before in my experience at Work4flow. The following code is a sample code that could help resolve the issue.
var demandTable = "dmn_demand";
if (GlidePluginManager.isActive('com.snc.project_management_v3')) {
demandTable = SNC.PPMConfig.getDemandTable(current.getTableName());
}
// Create the Demand
var demand = new GlideRecord(demandTable);
demand.setValue("description", current.description);
demand.setValue("requested_by", current.u_required_completion_date_if_any);
demand.setValue("portfolio", current.portfolio); // This works fine
// Check and set the u_global_process_shared_services_area field
if (current.u_global_process_shared_services_area) {
demand.setValue("portfolio", current.u_global_process_shared_services_area); // This should work if field is populated
}
demand.setValue("primary_program", current.u_program);
demand.setValue("priority", current.priority);
demand.setValue("short_description", current.short_description);
demand.setValue("type", "project");
demand.setValue("submitter", current.submitter);
demand.setValue("parent", current.sys_id);
demand.setValue("idea", current.sys_id);
var dmnId = demand.insert();
demand.get(dmnId);
current.demand = dmnId;
current.stage = 'demand';
GlideSysAttachment.copy('idea', current.sys_id, 'dmn_demand', demand.sys_id);
var link = ' <a href ="/' + demandTable + '.do?sysparm_query=number%3D' + demand.getValue('number') + '">' + demand.getValue('number') + '</a>';
var message = gs.getMessage("Demand {0} has been created");
message = message.replace("{0}", link);
gs.addInfoMessage(message);
Give it a try, and let me know if it doesn't work. I'd be happy to assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:36 AM
It does not work. 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 09:23 PM
Hi @Vaishnavi35 ,
The field is a custom field (as it's name begins with u_), as such it's tricky for me to know exactly why it's not working as it may depend on the field type and how it's setup. A few options/suggestions -
1. May not solve the issue, but it is recommended best practice to use getValue and setValue rather than dot walking - current.getValue('u_global_process_shared_services_area');
2. Does the custom u_global_process_shared_services_area field type differ from the OOTB portfolio field? The value used to update it could be different if it's a reference or choice for example.
Hope this is helpful.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:14 AM
Hi,
1. How do I write in the script using getVlaue and setValue? if you can help?
2. Both are same. But u_global_process_shared_services_area is a custom field reference to portfolio only.
Stakeholders wanted a different name on the portfolio form.
Thanks,
Vaishnavi