Working with Time Sheets, we wanted to add an alert if the person entering the data into the form is not the person whose time sheet it is.
On the form, I have:
A field named CurrentUserADUsername that defaults to: {/_currentuser}
A field named EmployeeADUsername that pulls in the employee's AD username from a DB Lookup
A field named CompareValues with this calculation: =IF(CurrentUserADUsername=EmployeeADUsername,"SAME","DIFFERENT")
An HTML field which contains the following:
"Data on this form was entered by {/dataset/_initiator_displayname} on {/dataset/employee_name}'s behalf."
And I'm using the following Javascript (where the HTML field is q1 and the CompareValues field is q2) to show/hide that HTML:
$(document).ready(function () {
$(document).on('lookup change', hideotheruserfunction);
function hideotheruserfunction() {
if($('#q1 input').val() == "SAME") {
$('#q2').hide();
} else {
$('#q2').show();
}
}
});
This all works perfectly: the HTML block displays if the current user name (on the input form) is not the same as the employee name. "Data on this form was entered by Cookie Monster on Big Bird's behalf."
Here's my problem: when the form becomes final, there is no longer a "Current User," so there is always a mismatch (username at that point becomes "Anonymous User"), and every form is showing the HTML with the Initiator Name and the Employee Name, like: "Data on this form was entered by Cookie Monster on Cookie Monster's behalf."
**Looks like "Anonymous User" isn't the only problem here; something else must be happening when the form enters a Read Only state that causes this HTML to be unhidden. ???
I searched this support site, and found some mention of this, but the responses weren't anything I could translate to fit my specific situation. Much earlier today, I had the idea to match on Initiator's UserID instead of Current User's UserID, but that field wasn't populating, so I didn't go down that path.
It's not strictly necessary for the HTML to display in the final resting version of the form. Can I maybe modify this calculation to take into account the "Anonymous User" (would want to return SAME in this case so the HTML would not display).
=IF(CurrentUserADUsername=EmployeeADUsername,"SAME","DIFFERENT")
I hope this all makes sense. Thank you in advance for any help you can provide!