Disabling field in relationship

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:

/////////////////////////////////////////////////////////////////////////////

var documentItem = document.thisItem;

documentItem.fetchRelationships("q_Quote Part");

var Xpath = "//Item/Relationships/Item";
var relationship = documentItem.getItemsByXPath(Xpath);
//alert(relationship.getItemCount());
if (documentItem.getProperty("state") == "Generate Quote") {
for (var i = 0; i < relationship.getItemCount(); i++) {

//var wrapper = relationship.getItemByIndex(i).getFieldByName("_quantity");
//var wrapper = getFieldByName("_quantity");
// wrapper.getElementsByTagName("input")[0].disabled = true;
}
}

///////////////////////////////////////////////////////////////////////////////////

I am currently having trouble targeting the field from the relationship tab. getFieldByName doesn't seem to be able to grab the wrapper if it is on the relationship tab. Any Input would greatly be appreciated!

  • 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');

    ...