Comparing variable references to the department table against a user's department table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I've got a catalogue item where a user can input new different departments into an existing business application:
What I'm wanting to add is check if the path to the current Business Owner's department aligns to the proposed Business Owning Business Unit/Function or Business Owning Platform. If it doesn't then inform the user that the current business owner does not sit within the proposed Business owning Business Unit and/or Platform.
The 'New Business Owning Business Unit or Function' displays options where the Department type is 'Function' or 'Business Unit' and 'New Business Owning Platform' displays options where the Department type is 'Platform'. I was just wondering if anyone has come across this before or something similar.
Generally, a a department with a type of 'Platform' is usually a child of a department with a type of 'Business Unit' or 'Function'. However, though, it can sometimes be that the grandchild department has a type of 'Platform', the parent department has a type of null, but the grandparent has a type of 'Business Unit' or 'Function'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
How would you setup the function in the script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Based on the client script you posted, the Script Include function only needs to do three things:
Accept the values passed from GlideAjax
Perform the validation logic server-side
Return a simple JSON response the client can evaluate
Below is the minimal, correct setup for the function in the Script Include that matches your onChange script exactly.
// Owner department is required to validate
if (!ownerDept) {
return JSON.stringify({
valid: true
});
}
// Validate BU alignment (example logic)
if (bu && !this._isAligned(ownerDept, bu, 'u_business_unit')) {
return JSON.stringify({
valid: false,
message: 'Proposed Business Unit does not align with the owner department.'
});
}
// Validate Platform alignment (example logic)
if (platform && !this._isAligned(ownerDept, platform, 'u_platform')) {
return JSON.stringify({
valid: false,
message: 'Proposed Platform does not align with the owner department.'
});
}
return JSON.stringify({
valid: true
});
},@matthew_hughes - Please give a thumbs up or accepted solution if you feel it was Helpful!
