- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:07 AM
Hello guys,
I got rather a special wish from our customer. We got a requested item where the users are able to create, update, retire, etc... an user record in the AD. There's a flow with AD integration, everything seems to be working alright except in one specific scenario. When user selects Create User in our catalog item, they're prompted to provide information such as first name, last name, location and also mobile and office telephone numbers (both mobile and office numbers are not mandatory because it's possible that when creating the user, the communication department haven't provided any mobile / office telephone number yet). The AD has those fields mandatory though so when the RITM is sent without telephone numbers specified, the AD is not able to create a user record, therefore, the RITM fails.
I simply need to populate (most probably country prefix only) into both telephone requested item variables once the RITM is created.
I'm not able to add this to our Flow since it's already taking all allowed rows.
I'm thinking of creating a business rule but I'm stuck with a code. Could you please advise how to populate those fields?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:44 AM
Hi @matej_h ,
I trust you are doing great.
To address the specific scenario where the AD integration fails due to missing telephone numbers in the requested item, we can implement a business rule in ServiceNow. The business rule will populate the telephone fields with a default value, such as the country prefix, when the record is created.
Here's an example of a business rule that can be used to achieve this:
// Business Rule: Populate AD Telephone Fields
// Table: Requested Item [sc_req_item]
(function executeRule(current) {
// Check if the record is being created
if (current.operation() == 'insert') {
// Check if the mobile telephone number is empty
if (current.variables.mobile_telephone.nil()) {
// Set the default value for mobile telephone number
current.variables.mobile_telephone = '+xx'; // Replace 'xx' with the desired country prefix
}
// Check if the office telephone number is empty
if (current.variables.office_telephone.nil()) {
// Set the default value for office telephone number
current.variables.office_telephone = '+xx'; // Replace 'xx' with the desired country prefix
}
}
})(current);
This business rule triggers whenever a new record is created in the Requested Item [sc_req_item] table. It checks if the mobile telephone number and office telephone number variables are empty, and if so, it populates them with the desired default value (country prefix).
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:33 AM
once RITM is submitted the flow is possibly picking the variable values. just before the AD step ensure you update the RITM record using custom flow action
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:34 AM
Hello @Ankur Bawiskar, as I said - we're already reached the limit of our Flow rows, we cannot add anything else to the flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 08:14 AM
then please use after insert BR
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:44 AM
Hi @matej_h ,
I trust you are doing great.
To address the specific scenario where the AD integration fails due to missing telephone numbers in the requested item, we can implement a business rule in ServiceNow. The business rule will populate the telephone fields with a default value, such as the country prefix, when the record is created.
Here's an example of a business rule that can be used to achieve this:
// Business Rule: Populate AD Telephone Fields
// Table: Requested Item [sc_req_item]
(function executeRule(current) {
// Check if the record is being created
if (current.operation() == 'insert') {
// Check if the mobile telephone number is empty
if (current.variables.mobile_telephone.nil()) {
// Set the default value for mobile telephone number
current.variables.mobile_telephone = '+xx'; // Replace 'xx' with the desired country prefix
}
// Check if the office telephone number is empty
if (current.variables.office_telephone.nil()) {
// Set the default value for office telephone number
current.variables.office_telephone = '+xx'; // Replace 'xx' with the desired country prefix
}
}
})(current);
This business rule triggers whenever a new record is created in the Requested Item [sc_req_item] table. It checks if the mobile telephone number and office telephone number variables are empty, and if so, it populates them with the desired default value (country prefix).
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi