Skip to main content

Hi,

 

What would be the best way of selectively locking fields on a screen on the SmartClient?

 

I am trying to disable certain fields on the project screen depending on the project status. This script below almost works, but diesnt lock the Notes tab records. Is there a better way of doing this? essentially, if the project is approved, the details cant be updated by everyone, only certain people (who use a different project screen).

We cant use the app param ‘FREEZE_PROJECT_APPROVAL_STATUS’ as some people will be allowed to update but not others.  The ones that it will be disabled for still need to be able to update the proect for any other status.

 

 

var lockFields=false;
var projectApprovalStatus = getControlValue("project","approval_status");

if(projectApprovalStatus=="APPROVED"){
    lockFields=true;
}    
if(lockFields){
setControlEnabled("project","project_title",false);
setControlEnabled("project","place_id",false);
setControlEnabled("project_text","text_id",false);
setControlEnabled("project_text","text_line_code",false);
setControlEnabled("project_text","text_rtf",false);
} else {
setControlEnabled("project","project_title",true);
setControlEnabled("project","place_id",true);
setControlEnabled("project_text","text_id",true);
setControlEnabled("project_text","text_line_code",true);
setControlEnabled("project_text","text_rtf",true);    
}

Hi @MartinF 

This is the way forward. I do not see any specific issue with your script.

Please try one of the following approaches

  1. Check again the value of lockFields
    if(lockFields == true){
    setControlEnabled("project","project_title",false);
    setControlEnabled("project","place_id",false);
    setControlEnabled("project_text","text_id",false);
    setControlEnabled("project_text","text_line_code",false);
    setControlEnabled("project_text","text_rtf",false);
    } if(lockFields == false){
    setControlEnabled("project","project_title",true);
    setControlEnabled("project","place_id",true);
    setControlEnabled("project_text","text_id",true);
    setControlEnabled("project_text","text_line_code",true);
    setControlEnabled("project_text","text_rtf",true);
    }
  2. Set the false/true value once
    var lockFields=false;
    var projectApprovalStatus = getControlValue("project","approval_status");

    if(projectApprovalStatus=="APPROVED"){
    lockFields=true;
    }

    setControlEnabled("project","project_title",lockFields);
    setControlEnabled("project","place_id",lockFields);
    setControlEnabled("project_text","text_id",lockFields);
    setControlEnabled("project_text","text_line_code",lockFields);
    setControlEnabled("project_text","text_rtf",lockFields);

 

  1. Try to replace the double quote with a single quote. For example
    setControlEnabled("project","project_title",false);
    -->
    setControlEnabled('project','project_title',false);

     

Cheers!


@Shneor Cheshin 

 

Thanks for your response. Its clearly not an issue with the value of the variable lockFields as its only the project_text commands that do not work.

 

Ill raise it as a bug


@MartinF did you ever figure out how to make a table project_text readonly? i have a similar requirement


Reply