Thursday, 11 October 2018

Aras Innovator disable a control after save

How to disable a control after save?
Prerequisites: Control property should be required field.
Solution:

Create new Item Type ex: TestItem

Add new properties
Ex: test1, test2 as string data type

Add new JS method: Ex: MyTest

For textbox control:

var myTestField = getFieldByName("test1");

//var myTestFieldValue = myTestField.querySelector("input[name='test1']").value;//Another way to get value
if (myTestField.value)
{
    setTimeout(function(){
        myTestField.getElementsByTagName("input")[0].disabled = true;
    }, 1);
}

For DDL (List Data Type):
var varMyddl = getFieldByName("mydll");

if (varMyddl)
{
    If(varMyddl.value){
        setTimeout(function(){      
            varMyddl.getElementsByTagName("input")[0].disabled = true;   
            varMyddl.getElementsByTagName("button")[0].disabled = true;

        }, 1);
    }

}

Open Item Type: TestItem
Under View, open TestItem form
Lock TestItem form
Click on  "Form Event"
Add method by click on +
Search for "MyTest"
Under Event, select "onFormPopulated"

Testing:
Create new item
Enter value for test1
Hit on Save
Now test1 control will be disable