Drop down value is not showing in workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi All,
I have created on load client script to add option in the field based on some validation.
Once the case created, stage field should display with Plan and when the case saved on stage status moved to complete, then adding next option in stage field. Here, once the case created the stage field displaying 'Plan' in platform view but not in workspace view and moving with next stage status, stage get updated with expected options in both view.
Please refer the attachment and script.
Your help will be appreciated.
function onLoad() {
filterStages();
function filterStages() {
var stagefield = 'stage';
var status = g_form.getValue('stage_status');
var currentstage = g_form.getValue('stage');
var stages = ['Plan', 'Build', 'Release', 'Proposals', 'Approval', 'Award'];
var currentindex = stages.indexOf(currentstage);
if (currentindex === -1) return;
g_form.clearOptions(stagefield);
if (status != 'Completed') {
if (currentindex > 0) {
for(var i = 0; i<= currentindex; i++){
g_form.addOption(stagefield, stages[i], stages[i]);
}
}
g_form.setValue('u_rfx_stage', currentstage);
} else {
if (currentindex > 0) {
for(i = 0; i<= currentindex; i++){
g_form.addOption(stagefield, stages[i], stages[i]);
}
g_form.addOption(stagefield, stages[currentindex + 1], (stages[currentindex + 1]));
}
else{
g_form.addOption(stagefield, stages[currentindex], (stages[currentindex]));
g_form.addOption(stagefield, stages[currentindex + 1], (stages[currentindex + 1]));
}
g_form.setValue('u_rfx_stage', currentstage);
}
}
}
@Ankur Bawiskar , Could you please help me on this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Is the UI type of client script set to All?
Also is the plan field added to workspace view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Yes, UI type is All.
Also is the plan field added to workspace view? - not sure, here 'Plan' is a option in stage field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Is the stage field on workspace?
I dont see anything in this script which stops it from working in workspace view, can you inspect the page and see the error in console?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Sivaprasath,
The script you wrote is correct — it works fine in the normal platform view. The reason it doesn’t show the 'plan' stage in Workspace when the case is first created isn’t because of your logic, but because of how Workspace loads forms differently.
In Workspace, the form fields (like the stage field) load a bit slower. So your script runs before the field is fully ready. That’s why the 'plan' option doesn’t appear right after creation, but works fine once the status changes (since the field is loaded by then).
To fix it, we need delay the function so it runs after the form is finished loading in Workspace
for ex..
if (window.NOW && NOW.workspace) {
setTimeout(filterStages, 500); // wait a bit for Workspace to load the field
} else {
filterStages();
}
This makes sure the logic runs at the right time in both Form and Workspace.
Also, when a record is new, you can set the default stage directly with
if (g_form.isNewRecord()) {
g_form.setValue('stage', 'Plan');
}
That's way, 'plan' will always show as the first value.
Please marked my answer is correct or helpful.
