- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I want when an request Item is created specially on workspace and Service desk agent clicks on SAVE then Source (contact_type) field should be Email, other wise when uses service portal then Source (contact_type) field should be Portal , tried through Client script it's working fine for portal but not on workspace.
Any suggestion how to acheive
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
You can replace your onSubmit Client Script with a Before-Insert Business Rule.
- Name: Set Contact Type by Source
- Table: Requested Item (sc_req_item)
- When: Before
- Insert: Checked
- Update: Unchecked
- Condition: contact_type is empty
(function executeRule(current, previous /*null when async*/) {
var action = gs.action.getGlideURI().toString();
var isWorkspace = action.indexOf('$sw.do') > -1 || action.indexOf('agent_workspace') > -1;
if (isWorkspace) {
current.contact_type = 'email';
} else {
current.contact_type = 'portal';
}
})(current, previous);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
why are you using onSubmit?
I suggested to use onLoad and normal client script on RITM table which won't impact the catalog item on portal
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
You can replace your onSubmit Client Script with a Before-Insert Business Rule.
- Name: Set Contact Type by Source
- Table: Requested Item (sc_req_item)
- When: Before
- Insert: Checked
- Update: Unchecked
- Condition: contact_type is empty
(function executeRule(current, previous /*null when async*/) {
var action = gs.action.getGlideURI().toString();
var isWorkspace = action.indexOf('$sw.do') > -1 || action.indexOf('agent_workspace') > -1;
if (isWorkspace) {
current.contact_type = 'email';
} else {
current.contact_type = 'portal';
}
})(current, previous);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti