<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Disabling field in relationship</title><link>https://www.aras.com/community/f/development/5702/disabling-field-in-relationship</link><description>Hi all, 
 I am currently trying to disable a field on the relationshiptab when the item is at a certain state. 
 The method is current run under onFormPopulated. 
 Below is my code: 
 //////////////////////////////////////////////////////////////////</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: Disabling field in relationship</title><link>https://www.aras.com/community/thread/2652?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 10:44:57 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:0f5b87b9-823e-4209-a684-034fe2106994</guid><dc:creator>carstenw</dc:creator><description>&lt;p&gt;Hi philn,&lt;/p&gt;
&lt;p&gt;I faced the same challenge as you in the following scenario:&lt;/p&gt;
&lt;p&gt;We have a custom item type Part Request with a relationship to a Manufacturer Part. Unless the Part Request is in the LC state &amp;#39;Awaiting AML Approval&amp;#39; the field &lt;strong&gt;is_approved&lt;/strong&gt; on the relationship cannot be edited.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I looked to the Programmer&amp;#39;s Guide pp. 63-64 and found inspiration for the following:&lt;/p&gt;
&lt;p&gt;This client method needs to be placed on the Property is_approved. Pro tip: This item type can only be locked when the parent item type (Part Request in my scenario) is locked first. Once the Property is locked, add a new client method with the Event&amp;nbsp;&lt;strong&gt;OnEditStart&lt;/strong&gt; with the following content:&lt;/p&gt;
&lt;p&gt;var inn = this.Innovator();&lt;/p&gt;
&lt;p&gt;var relationship = inn.newItem(&amp;#39;PartRequest ManufacturerPart&amp;#39;, &amp;#39;get&amp;#39;);&lt;br /&gt;relationship.setProperty(&amp;#39;id&amp;#39;, relationshipID);&lt;br /&gt;relationship = relationship.apply();&lt;/p&gt;
&lt;p&gt;var prq = inn.newItem(&amp;#39;Kam_PartRequest&amp;#39;, &amp;#39;get&amp;#39;);&lt;br /&gt;prq.setProperty(&amp;#39;id&amp;#39;, relationship.getProperty(&amp;#39;source_id&amp;#39;));&lt;br /&gt;prq = prq.apply();&lt;/p&gt;
&lt;p&gt;var prqState = prq.getProperty(&amp;#39;state&amp;#39;);&lt;/p&gt;
&lt;p&gt;if(prqState === &amp;#39;Awaiting AML Approval&amp;#39;) {&lt;br /&gt; return;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;var cellValue = gridApplet.GetCellValue(relationshipID, colNumber);&lt;br /&gt;if(cellValue !== &amp;#39;&amp;#39;) {&lt;br /&gt; return false;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Small note&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;The magic arguments &lt;strong&gt;relationshipID&lt;/strong&gt; and &lt;strong&gt;colNumber&lt;/strong&gt; along with &lt;strong&gt;gridApplet&lt;/strong&gt; is given by the anonymous method containing your method code, like so&lt;/p&gt;
&lt;p&gt;(function anonymous(relationshipID,relatedID,propertyName,colNumber,gridApplet&lt;br /&gt;) {&lt;br /&gt;debugger;&lt;br /&gt;var inn = this.Innovator();&lt;/p&gt;
&lt;p&gt;var relationship = inn.newItem(&amp;#39;PartRequest ManufacturerPart&amp;#39;, &amp;#39;get&amp;#39;);&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>