fiscal
You can create two (or more) buttons and hide the ones that don’t apply in a given situation. For example, say I have a button that uploads a file for a given record and the label is “upload file”. Once that record has an uploaded file registered with it, if that record is then edited, I want the button to say “delete uploaded file” instead of “upload file”.
So, I have 2 buttons on a form (used to edit / add a new “master” record) - an upload one (uploadfile) and a delete one (deletefile). On the form’s onLoad event I have:
if (trim({TSLink}) == '') {
{TSLink} = "No file uploaded.";
sc_btn_display('uploadfile', 'on');
sc_btn_display('deletefile', 'off');
} else {
{TSLink} = '<a href="' . [fp] . {SignedTimesheet} . '" target="_blank">' . {SignedTimesheet} . '</a>';
sc_btn_display('deletefile', 'on');
sc_btn_display('uploadfile', 'off');
}
TSLink is a field showing a hyperlink to the uploaded file - if it’s empty (i.e. no file has been uploaded for this record) then give the field some meaningful text and display the upload button and hide the delete button. If TSLink is not empty (i.e. a file has been uploaded for this record), then make the filename a hyperlink and hide the upload button, and show the delete button.
NOTE: it’s in onLoad in this instance as the form only shows a specific record - you cannot navigate records with it. If you are going to navigate through records then the above will need to be in onNavigate I would imagine.