how to make field read only on the other form without using ui policy

Teja3
Tera Contributor

 

Teja3_0-1746615143640.png

Teja3_1-1746615307944.png

 

 

here in the above table whenevr state is updated to missing we have configuration item field which is referenced to cmdb_ci table in this table some fields like assigned_to etc.. these fields should be made as read only
i tried ui policy actions  dot walking on ci table but its not working could anyone provide me solution for this

Thanks

6 REPLIES 6

Robert H
Mega Sage

Hello @Teja3 ,

 

Please configure the Computer CI form and add the "Asset.State" field.

 

RobertH_1-1746618922077.png

 

Then create the UI Policy on the cmdb_ci_computer table, with the condition Asset.State = Missing, making the Assigned to read only.

 

RobertH_2-1746619151003.png

 

Regards,

Robert

 

 

VikMach
Mega Sage

@Teja3- You will have to create this UI Policy from cmdb_ci_computer table and dot walk from Asset field which is already mapped to alm_asset related record.
See snip below.

Vikas1_0-1746619833772.png

 

Vikas1_1-1746619904007.png



Result -

Vikas1_2-1746619931228.png



Let me know if it worked!

Regards,
Vikas K



Ankur Bawiskar
Tera Patron
Tera Patron

@Teja3 

so on cmdb_ci record you want some fields to be read-only if the Hardware record is with State as Missing?

you can use display business rule on cmdb_ci_computer table and get the state of asset and store in g_scratchpad variable

Display BR:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    if (current.asset.state.toString() == '8')
        g_scratchpad.makeReadOnly = 'true';
    else
        g_scratchpad.makeReadOnly = 'false';
		
})(current, previous);

Then use onload client script on cmdb_ci_computer table and use that scratchpad variable

function onLoad() {
    if (g_scratchpad.makeReadOnly == 'true') {
        g_form.setReadOnly('assigned_to', true);
        // add other field also
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for your solution.
Actually not only on cmdb_Ci_computer table in the alm_hardware table where we have current ci field which is reference to the other table in that we need to set read only for some fields

Teja3_0-1746702483311.png