Credential password update using schedule job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi All,
I have a requirement where a credential in All → Credentials should have its password updated automatically every month in a specific format (for example: Doraemon@MMYY like Doreamon@0526, Doreamon@0626 ....).
I created a scheduled job script in my PDI, and it shows that the password is getting updated. However, I want to confirm whether the password is actually updated in the same format as defined in my script.
Is there any way to check or verify the updated password value through a script or by setting up an email notification to see the password?
I have attached a screenshot for reference.
1. Credential Name:
2. Credential Updated:
3. Schedule Job script:
(function() {
//Password generate (Reports@MMYY)
var now = new GlideDateTime();
var month = now.getMonthUTC() + 1;
var year = now.getYearUTC().toString().slice(-2);
if (month < 10) {
month = '0' + month;
}
var newPassword = 'Doraemon@' + month + year;
//Credential record fetch
var gr = new GlideRecord('discovery_credentials'); // <-- table
gr.addQuery('user_name', 'Reports@1234.com');
gr.query();
if (gr.next()) {
//Password update
gr.setDisplayValue('password', newPassword);
gr.update();
gs.info("Password updated: " + newPassword);
} else {
gs.error("Credential not found");
}
})();
