Disabling field in relationship
- 7 years ago
Hi philn,
I faced the same challenge as you in the following scenario:
We have a custom item type Part Request with a relationship to a Manufacturer Part. Unless the Part Request is in the LC state 'Awaiting AML Approval' the field is_approved on the relationship cannot be edited.
I looked to the Programmer's Guide pp. 63-64 and found inspiration for the following:
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 OnEditStart with the following content:
var inn = this.Innovator();
var relationship = inn.newItem('PartRequest ManufacturerPart', 'get');
relationship.setProperty('id', relationshipID);
relationship = relationship.apply();var prq = inn.newItem('Kam_PartRequest', 'get');
prq.setProperty('id', relationship.getProperty('source_id'));
prq = prq.apply();var prqState = prq.getProperty('state');
if(prqState === 'Awaiting AML Approval') {
return;
}var cellValue = gridApplet.GetCellValue(relationshipID, colNumber);
if(cellValue !== '') {
return false;
}Hope this helps;
Small note:
The magic arguments relationshipID and colNumber along with gridApplet is given by the anonymous method containing your method code, like so
(function anonymous(relationshipID,relatedID,propertyName,colNumber,gridApplet
) {
debugger;
var inn = this.Innovator();var relationship = inn.newItem('PartRequest ManufacturerPart', 'get');
...