How to:
1. get logged-in user name
2.get raised by name (from previously created record)
3. compare both - if same show edit button/ field/ etc.. if not hide
Any ideas, examples of JS?
How to:
1. get logged-in user name
2.get raised by name (from previously created record)
3. compare both - if same show edit button/ field/ etc.. if not hide
Any ideas, examples of JS?
Depending on where the "Get Raised By Name" is on your page. You can create a comparison to compare the Knack.getUserAttributes().name with the value from the "Raised By Name".
For example, if your edit button is on a view and we perform a view render:
$(document).on('knack-view-render.view_XXX', function(event, view, record) {
// Hide your values initially so there's no awkward UX when loading the view
$(knackEditButtonId).show();
$(knackEditFieldId).show();
$(knackEditEtcId).show();
// Define the variables to compare
const raisedByName = 'find raised by value from view on page'
const loggedInUser = Knack.getUserAttributes().name
// Create Conditional Check to compare the values
if(raisedByName === loggedInUser) {
$(knackEditButtonId).show();
$(knackEditFieldId).show();
$(knackEditEtcId).show();
}
}