Scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 09:01 PM
How to fetch the details from flow designer (particular flow) that has to run after all the stages are completed.The field(date field) will get updated,through scheduled job that has to check the date field and execute the provision and deprovision of roles on that date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 10:06 PM
Hi @HARSHA GOWDA R
could you please explain your requirements a little more for better understanding??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 10:18 PM
There is a catalog item called "Title change",under this item there is a variable called effective date,so if effective date is empty then after the approvals the new roles are activated and existing roles are deactivated through flow i have done.If the effective date is not empty (some future date is filled in that field) through flow there is field in our custom table ,in that field the effective will get updated and through scheduled job it has to check daily and if the date matches then the new roles should be activated and exisiting roles should be deactivated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2024 10:10 PM
meanwhile create a schedule job that runs daily,
(function() {
// Query the table with the date field to check against today’s date.
var gr = new GlideRecord('your_table');
gr.addQuery('date_field', '=', gs.nowDateTime());
gr.query();
while (gr.next()) {
// Add business logic to provision roles
provisionRole(gr);
// Add business logic to de-provision roles
deprovisionRole(gr);
// Update a field if needed to mark the action as completed
gr.setValue('status_field', 'processed');
gr.update();
}
// Function to provision role
function provisionRole(record) {
// Example code to provision roles
var userRole = new GlideRecord('sys_user_has_role');
userRole.initialize();
userRole.user = record.user; // Assuming ‘user’ field contains the user for which roles are to be provisioned
userRole.role = 'desired_role'; // Replace ‘desired_role’ with the actual role ID
userRole.insert();
}
// Function to deprovision role
function deprovisionRole(record) {
// Example code to deprovision roles
var userRole = new GlideRecord('sys_user_has_role');
userRole.addQuery('user', record.user); // Assuming ‘user’ field contains the user for which roles are to be de-provisioned
userRole.addQuery('role', 'desired_role'); // Replace ‘desired_role’ with the actual role ID
userRole.query();
if (userRole.next()) {
userRole.deleteRecord();
}
}
})();
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma