Is there a way to remove the new button on a related list based on a Form's Field Value?

Navaneeth1
Tera Guru

Could someone please let me know if there's a way to remove the new button from related list based on a Form's Field Value?

find_real_file.png

Referring the image above (also attached with this post), I need the new button on the related list to be made in-accessible once the "Status" field on the form is updated to "Completed" choice.

The related list (Tasks) only shows records associated with a particular form.

I noticed that omit New button can be used in list control but I can't seem to pass the field value from the form to the condition script.

Is there a way to access the "Status" field value from the form and pass it into the Omit new Button Script condition?

Or is there any other way to make the New Button unavailable after that Field value change?

Thank you in advance!

 

 

1 ACCEPTED SOLUTION

parent is your form object.

if (parent.status == <value>)
true; // Show the New button
else
false;

Please update the value of status and try. 

For your reference:-

find_real_file.png


Thanks & Regards,
Vasanth

View solution in original post

6 REPLIES 6

Vasantharajan N
Giga Sage
Giga Sage

You can use Omit new condition scripting field to check the status of the parent record state. 

find_real_file.png


Thanks & Regards,
Vasanth

Hello @Vasantharajan N ,

I appreciate the response!

I've mentioned in the description, I already tried this but I don't know how to access the field values from the form to be used in the if condition since the filed is on another table/form.

If it's not too much to ask, Could you please provide the code for the condition?

Thank you so much in advance! 

Could you please provide the form table name and the filter on the related list (Which filter is applied to task table )


Thanks & Regards,
Vasanth

Hello @Vasantharajan N ,

The form table name is "x_dasf_status_reports", the table field name to be referred from the form is "status" and the filter applied to the related list is actually a relationship script:

(function refineQuery(current, parent) {

	current.addQuery('id', parent.sys_id);
	

})(current, parent);

parent is "x_dasf_status_reports" and current is "Tasks" table.

There is a field in tasks table called "id" which stores the sys_id of particular status reports so that each task can be mapped to a status report.

The id field is automatically populated when a NEW task is created from the Status Report Related List.

Thank you so much in advance!