How to disable delete relationship button based on parent item state?

I know this question has been asked multiple times and I have reviewed all the ones that had answers. None of them seemed to clearly lead me in the right direction.

I feel what I'm trying to do is a pretty basic use case. I'm trying to prevent affected items from being deleted or added based on the lifecycle state of the ECN. I feel the following is the most user friendly way to achieve this.

For the ECN Item, I want to disable the "Delete ECN Affected Item" button when the ECN state is (In Review or Released state).

Is this recommended? If so, please provide an example.

If not, what is the preferred method to achieve this with a good user experience?

Parents
  • Here is my complete solution for disabling the delete button when the ECN is In Review status or after.

    Open the ECN Item and go to Relationships tab. For this example, I am changing the ECN Affected Item.

    Open the ECN Affected Item (Not the relationship)

    - Go to Client Style

    - Create a new Presentation Configuration (If already exists, just open the existing one)

    Create a new CommandBarSection.

    Open CommandBarSection created above.

    - Add the existing Command Bar Item: itemview.relationshipscommandbar.default.deleterow

    - Enter remaining fields per screen shot, except the Alternate. (we have to create this first)

    Copy method:  cui_ivrcb_deleterow_init and create a new method. Adjust the if statement as needed based on the LifeCycle States you want the button disabled for.

    let isDisabled = true;
    if (window.computeCorrectControlState) {
    isDisabled = !window.computeCorrectControlState('delete');

    let parentItemLifeCycleState = parent.thisItem.getProperty('state', null);

    if (parentItemLifeCycleState === 'In Review' || parentItemLifeCycleState === 'Checker'
    || parentItemLifeCycleState === 'Final Approval' || parentItemLifeCycleState === 'Released')
    {
    isDisabled = true;
    }

    }
    const tooltip = target.tooltip_template.replace(
    '{0}',
    options.relationshipItemTypeLabel
    );
    return {
    disabled: isDisabled,
    tooltip_template: tooltip
    };

    Open the Command Bar Item above (this will open the existing Command Bar Item)

    - Click the ... -> Create New Button

    - Fill in the fields as shown.

    The delete button should now be disabled when the ECN is not in New or In Work states. 

    - If you are not getting the results you expect, clear your Metadata cache.

  • Wow, what an answer, thanks for sharing! I am happy to see we get more and more people who raise the quality of posts in this forum! You even use dynamic labels/tooltips!

      If you need some ideas for the community reboot Aras is currently working on: Aras from time to time could write some blog posts that highlight some TechTips or discussions from community. A lot of the useful stuff is often hard to find. This one is a perfect description of how to use init Methods. I wish I had had these kind of guide years ago!

  • Thanks Angela, I'll keep that in mind!

Reply Children
No Data