Link in children's Item Type view to the parent's Item Type view

Hello everyone,

Try explain, my scenario:

I have the Item Types related:

1° Item type Authorization.
2° Item type AuthorizationTittle.
3° Item type AuthorizationTittleRelation (only to related).

I need add a link or buton in AuthorizationTittle with a phisical link/url to open a view of your Authorization Parent.

Thanks.

Parents
  • Simplest way to get a connection is to unhide the "related_id" property in your Relationship ItemType (the 2nd one). Just as done in Part AML. 

  • Hello, thanks for the answer.

    Let me see if I understand, the Item Type "AuthorizationTittleRelation" is filled only when saving the view in Authorization and need to discover the ID of the parent(Authorization) when I save the AuthorizationTittle in this moment I don't have yet the AuthorizationTittleRelation.

    If you can pass on more details, it'll help me a lot.

    Thanks.

  • I am not sure if you are looking for something standard or something more complex. 

    If you can provide a screenshot or drawing where you show which data shall be displayed where, it will probably help even more :-)

  • Hello, I have two forms one to insert new "Authorization" this below picture, and when I click in the in the button plus the new form is opened, to insert the new "AuthorizationTittle" second picture, and the issue is that I need the Authorization ID before save the AuthorizationTittle, second form.

    Thanks.

  • Much better! Slight smile

    If your related item would be just a null-relationship things would be easy, cause you simply use the "source_id" property in your form.

    If you have a related item with a relationship in between, things get more complicated. Problem: You can have more then one parent items.

    Do you really need your mentioned "Authorization ID", or do you just search for a backlink option?

    For viewing parent items the classical approach would be to use some kind of "Where Used / Parent items" tab with a TreeGridView that displays all parents of the item. For example ItemType "Manufacturer" uses this approach.

    A custom html field in the Form that shows the ids or source elements itself would also be possible, but requires much more programming.

  • Thanks again,

    I really need the Authorization ID before save the AuthorizationTittle, and I cant have in the AuthorizationTittle's form a selection list of Authorizations, this would have to be transparent to the user.

    Do you have any more suggestions?

    Thanks.

  • OK, then just some ids? Which event type do you use?

    Depending on the event, your code would look something like this:

    Item findParent = inn.newItem("nameOfRelationship","get");
    findParent.setProperty("related_id","mytitulosid");
    findParent.setAttribute("select", "source_id");
    findParent = findParent.apply();

    Item result = findParent.getItemByIndex(0).getProperty("source_id","");

    return inn.newResult("Result: " + result);

    You can try it in the Method editor first with hardcoded values.

  • Hello,

    I tried something like this, in the before and after add in AuthorizationTittle, but the issue is that the RelationshipItemType is filled only in the save of the Authorization(parent) form.

    It's a big issue.

    Thanks.

  • Ok I slowly understand your problem. In this case you cannot use onBeforeAdd/Update.

    You need either a ItemType Client Event or a RelationshipType event. I am not sure right now cause I never had tested it by myself.

    I would start with an onInsertRow event in RelationshipType:

    Get the parent id with something like this: parent.thisItem.getID();

    Then add the id automatically to the related item (check out Method 'Increment Sequence Number'). Approach with ItemType Event would be some kind of similar. 

  • Hello, angela,

    Firstly thanks for the tips.

    I got a solution, I'll try to explain it to you.

    • 1° In the AuthorizationTittleRelation(relation item), I added the JS in the event OnInsertRow and this JS recover the parent.thisItem.getID() and set a document.cookie "currentAuthorizationJSON".
    • 2° In the AuthorizationTittle more specific in the form, I add the JS in the event OnFormPopulated that do this below.
      FYI: The z_authorization(Item is your type) is my field in the AuthorizationTittle the related with Authorization.

    if (document.thisItem.getProperty("z_authorization") === undefined ||
    document.thisItem.getProperty("z_authorization") === null ||
    document.thisItem.getProperty("z_authorization").trim() === '') {

    var currentAuthorizationObj = JSON.parse(getCookie('currentAuthorizationJSON'));

    document.thisItem.setProperty("z_authorization", currentAuthorizationObj.id);
    }

    • 3° And to have the link to Authorization in the AuthorizationTittle's form I added in the form the field of the Item Type(z_authorization) with Disabled checked.


    Thanks.

  • Happy to hear you solved it!

Reply Children
No Data