Hide field on form grid coloumn

hi gurus
how to hide grid coloumn using COC
for the form InventTransDetails in the reference tab (part) you have grid coloumn for cost price
i want to hide this.
Please advice
regards

Which part of your requirement are you struggling with?
Do you want to hide the field in all cases or conditionally?
Which form part do you mean? Do you want to change it at all places, or only if it’s used in InventTransDetails form?

thank you sir for the reply
i want to hide the cost price and line amount in the form inventtransdetails at the “reference” form part whcihc is a grid and the values are not direct table fileds but calculated fields
this I have to do because i cant restrict the normal users from security level.
I have to stop some users only in inventtransdetials form.

Sorry, it’s still not clear to me what you mean. You said it’s in InventTransDetails form, but they you mentioned a form part, but a form part would be a different form. Can you please give us names of those controls (and confirm in which form they’re placed)?
In general, you need to get a reference to a control and call pass false to its visible() method. E.g.:
LineAmount.visible(false);

image

i was referring the section (References) as form part. apologies for the confusion

Thank you. “References” is a fast tab, not a form part.
You didn’t include the information about control names. Either you forgot or you don’t know how to find it. It’s simple - right-click the column label (e.g. Unit price), highlight Form information and notice the value of Control Name. Or you can look into Visual Studio.
It seems that you’re talking about RealEdit2 and RealEdit. Now you know what code you need.
Another question is where your code should be placed. I would use CoC on init() method of InventTransDetails form.

yes sir i was not knowing it ( fast tab) i am still learning,
thank you very much for the reply

below is the script and it is working
thanks mr martin

[ExtensionOf(formStr(InventTransDetails))]
final class InventTransDetails_Form_Extension
{
public void init()
{
next init();
if ( ! isSystemAdministrator())
{
realedit2.visible(false);
realedit.visible(false);
}
}

}

Let me format your code:

[ExtensionOf(formStr(InventTransDetails))]
final class InventTransDetails_Form_Extension
{
	public void init()
	{
		next init();
	
		if (!isSystemAdministrator())
		{
			realedit2.visible(false);
			realedit.visible(false);
		}
	}
}

But I wonder why you need code for it all all. Here is my idea: Create a privilege that deny access to these two form controls and assign this privilege to System user role. System administrators bypass permissions, therefore it shouldn’t apply to them. Doesn’t it meet your requirements?

Ok sir i will try that