Dependency to make field read-only after add relationships from the subpanel

I want to make the field read-only after add relationships from the subpanel. From the subpanel, I am pulling one field value from a related module and save in the parent module filed. Then I want to make the parent module filed read-only.

And want to read-only always if the relationship record is available else need to remove read-only.

Parent Module:

Related Module:

  • Let me know if I got the idea:

    Parent module has subpanel of module Inventory Management.

    Parent module has the field Storage Condition whose value come from field End Condition in related module Inventory Management.

    The field Storage Condition on parent module should be readonly if it has been linked a record in subpanel of Inventory Management.

    Is that right?

    If so then I have some questions:

    What should happen if 2 or more records are linked through subpanel Inventory Management? Should Storage Condition on parent module be updated according to latest linked Inventory Management?

    I suppose the relationship between parent module and Inventory Management is M:M, right? If so then regular dependencies will not work.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • The field Storage Condition on parent module should be readonly if it has been linked a record in subpanel of Inventory Management.

    Is that right?

    Yes, right.

    laxmichand

  • What should happen if 2 or more records are linked through subpanel Inventory Management? Should Storage Condition on parent module be updated according to latest linked Inventory Management?

    If I have more then one linked record then it will be update according to latest linked Inventory Management.

    laxmichand

  • Relationship is many to many

    laxmichand

  •  You should be able to use Dependencies to make it read-only with the following Sugar Logic formula:

    greaterThan(count(inventory_management_relationship_name),0)

    You will need to use a different mechanism to get the value from the most recent IM record. Maybe write a new SugarLogic function to get maxRelatedDateValue.

  • This is an old post, but I tried it today in v14 Ent and I can't even save the fomula, it gives me a mismatched bracket which there is none.

    In my case the relationship is 1:M (one PGOpp many Ledger entries), I used the link name in the formula but it doesn't like that.

    greaterThan(count(pgopp_partnershipopportunities_apib_apibillingledger_1),0)

    if I enter the formula in code, it accepts it just fine (no errors reported) but does not enforce it.

    $dictionary['pgopp_PartnershipOpportunities']['fields']['amount']['readonly_formula']='greaterThan(count(pgopp_partnershipopportunities_apib_apibillingledger_1),0)';

    Any idea why?

    Francesca

  • Hi  ,

    When using the count query, your relationship name should be preceded by a $. In other words, the formula should read:

    Fullscreen
    1
    2
    3
    4
    5
    6
    greaterThan(
    count(
    $pgopp_partnershipopportunities_apib_apibillingledger_1
    ),
    0
    )
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Chris

  • Thank you  !

    Odd though that the error message is so off the mark.

    With the $ it does now accept the formula but it doesn't make the field read-only as I had wanted.