unable to see any changes on Incident table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@neelamallik
The issue is not with the Incident table.
Your script is a Client Script (onSubmit) so it only runs in the browser and does not update or modify any Incident table data.
What your script actually does
It only validates the form before submission.
If the condition fails, it blocks the submit.
If the condition passes, the record is saved normally.
function onSubmit() {
var knowledgeFlag = g_form.getValue('knowledge');
var knowledgeArticle = g_form.getValue('knowledge_article');
if (knowledgeFlag == 'true' && !knowledgeArticle) {
alert('Please select a knowledge article before submitting the form');
return false;
}
return true;
}
*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @neelamallik,
Can you please clarify the requirement here?
Also, confirm where this script is running. This is an onSubmit Client Script, so it must be configured on the Incident form to take effect. If it’s placed on another form it won’t reflect on Incident form
Regards,
Mohammed Zakir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @neelamallik ,
Try your if condition like below
if (knowledgeFlag == 'true' && !knowledgeArticle.trim()) {
alert('Please select a Knowledge Article before submitting the form');
return false;
}
OR
if (g_form.getValue('knowledge') == 'true' && !g_form.getValue('knowledge_article')) {
alert('Please select a Knowledge Article before submitting');
return false;
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @neelamallik ,
The script you’ve shared is an onSubmit Catalog Client Script, but there are a few important points to keep in mind when working with the Incident table:
Client Scripts vs. Table Updates
- onSubmit() scripts only run in the form UI (Service Portal or native UI).
- They don’t directly update the Incident table — they just prevent or allow submission.
- If you’re expecting the Incident record itself to change, you’ll need a Business Rule or UI Action instead.
Field Names
- g_form.getValue('knowledge') and g_form.getValue('knowledge_article') will only work if those are actual field names on the form.
- Double‑check that the names match the variable/field dictionary entries.
Error Messaging
- Instead of using alert(), consider using:
g_form.addErrorMessage('Please select a Knowledge Article before submitting');This displays the message inline and is more user‑friendly in both UI and Service Portal.
function onSubmit() {
var knowledgeFlag = g_form.getValue('knowledge');
var knowledgeArticle = g_form.getValue('knowledge_article');
if (knowledgeFlag === 'true' && (!knowledgeArticle || knowledgeArticle.trim() === '')) {
g_form.addErrorMessage('Please select a Knowledge Article before submitting the form');
return false; // prevents submission
}
return true;
}
--------------------------------------------------------------------------------------------------------------------------------------------
If my response helped, please mark it as the accepted solution so others can benefit as well.
Regards,
Divesh Tyagi
