Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2024-10-21 06:06 AM
Currently, there is no existing solution to retrieve the first name, last name, or email ID of a user listed in the record permission (RP) field through calculations or other methods. However, we do have the ability to obtain the user system ID using calculations based on the RP field.
Once we have the user system ID, this script utilizes it to access the user details via the REST API. This approach allows us to retrieve relevant user information, such as the first name, last name, and email address. The fetched data can then be stored in designated text fields within the application, facilitating efficient data management and user interaction.
2024-10-21 03:19 PM - edited 2024-10-21 03:23 PM
@Sanjeev_uvs_00 Thanks for sharing this but it doesn't seem to be working for me. Where in the code do we define the referenced record permissions field? Shouldn't we enter the RP field ID somewhere so the code knows which field to look at?
2024-10-21 07:55 PM
The way you reference the RP field is on line 20, where it has "const UserSysId = document.getElementById("master_DefaultContent_rts_s4893_f23682c").innerText;"
The part between the brackets (master_DefaultContent_rts_s4893_f23682c) is the reference to the field. However for me, updating that to be my RP field didn't actually work, as the code is expecting a userID, but that just pulls the user's name from the field for me. I actually had to create a new calculated text field which just pulls the RP field, and update the code to reference that text field.
It pulls the first and last name fine, but isn't actually pulling the email for some reason. I haven't played around with it too much though to troubleshoot.
2024-10-22 12:06 PM
Hi @JordanG ,
It seems that the code for retrieving the user email details was missed in the documentation. You can use the following Ajax function to get the user's email ID:
This function fetches the user's contact details using the UserSysID and updates the specified text field with the email address.
/*// Ajax function to get user email details
function GetContactDetails(UserSysID) {
return new Promise((resolve, reject) => {
const csrfToken = window.sessionStorage.getItem("x-csrf-token");
const baseURL = `${window.location.protocol}//${window.location.host}${parent.parent.ArcherApp.globals['baseUrl']}`;
const URL = `${baseURL}/api/core/system/usercontact/${UserSysID}`; // Use UserSysID in the URL
const headers = {
'x-csrf-token': csrfToken,
"X-Http-Method-Override": 'GET'
};
$.ajax({
headers: headers,
type: "POST", // Use POST to handle CSRF but override as GET
url: URL,
data: '',
contentType: 'application/json',
processData: false,
dataType: 'json',
success: function (data) {
if (data.IsSuccessful) {
const contact = data.RequestedObject;
if (contact) {
setTextField(EmailTextFieldID, contact.Email || '');
}
resolve(data); // Resolve the promise with user data
} else {
console.log("Request was not successful.");
reject("Request failed");
}
},
error: function (data) {
console.log(data);
reject(data); // Reject the promise on error
}
});
});
}*/
2024-10-22 06:35 PM
Thanks very much for that!
2024-10-31 05:28 AM
@Sanjeev_uvs_00 - Is extract via REST API the only way to pull the needed user attributes? It would be helpful to dump the attributes such as email from the RPF to a text field for a more native report export.
2024-10-31 09:54 AM
@Sanjeev_uvs_00 - It appears the REST API option only works from the Contacts application. Is that correct?
Thanks!
Thomas
2024-11-20 11:28 PM
Yes, I think using the system ID is a way to extract the user details from a record permission field if you want to use them further. You can do this via the following endpoint:
baseURL/api/core/system/usercontact/UserSysID.
2024-11-20 11:28 PM
No, it's not working based solely on the Contacts application. It will work based on the system user ID.