Skip to main content
Answer

Disable Action issue

  • December 2, 2025
  • 2 replies
  • 22 views

Forum|alt.badge.img

I created a new screen that has workflow code on it. i followed the T270 series to make it. I am having issues with disabling an action conditionally. I want the “Remove Hold” button to be disabled whenever a line item is added that has a “Stock Replenishment Type” of “Manufacture” and the Bar ID is null. In the below picture, the removed hold button should be disabled because line 1 and 3 are empty in the bar id. i have the field conditionally required, but it will still put it on hold even though an error will pop up saying that the field has to be filled out. i tried adding it in a row selected event. i also tried to do it in the workflow. but it doesnt ever get disabled. can someone tell me what i am doing wrong?

protected void _(Events.RowSelected<ProtoCutLine> e, PXCache cache)
{
    ProtoCutLine row = e.Row;
    ProtoCut lineitems = SelectFrom<ProtoCut>.Where<ProtoCut.orderID.IsEqual<ProtoCutLine.orderID.FromCurrent>>.View.Select(this);

    if (lineitems.Status != "OH") //return;
    {
        // Make the entire grid read-only
        e.Cache.AllowUpdate = false;
        e.Cache.AllowInsert = false;
        e.Cache.AllowDelete = false;
        PXDefaultAttribute.SetPersistingCheck<ProtoCutLine.barID>(cache,null,PXPersistingCheck.NullOrBlank);
    }
    else
    {
        e.Cache.AllowUpdate = true;
        e.Cache.AllowInsert = true;
        e.Cache.AllowDelete = true;
        PXDefaultAttribute.SetPersistingCheck<ProtoCutLine.barID>(cache, null, PXPersistingCheck.Nothing);
    }

    if (row.StkRepType == "M")
    {
        PXDefaultAttribute.SetPersistingCheck<ProtoCutLine.barID>(cache, null, PXPersistingCheck.NullOrBlank);

    }
    else
    {
        PXDefaultAttribute.SetPersistingCheck<ProtoCutLine.barID>(cache, null, PXPersistingCheck.Nothing);

    }

    //if (row.BarID == null) //row.StkRepType == "M" &&
    //{

        ReleaseFromHold.SetEnabled(false);

    //}


}

 

public class Conditions : Condition.Pack
{

    public Condition NotDone => GetOrCreate(b => b.FromBql<
        // Where<Selector<ProtoCutLine.orderID, ProtoCutLine.stkRepType>,Equal<Manufactured>,And<ProtoCutLine.barID.IsNull>>>());
       

}

 

 

.WithActions(actions =>
 {
     actions.Add(g => g.ReleaseFromHold, c => c
             .WithCategory(processingCategory)
             .IsDisabledWhen(conditions.NotDone));

Best answer by justen0351

@Abhishek Niikam thanks for the response. I really appreciate it. I looked at the sales order screen and mine is functioning the say way that it is so i am just going to leave it as is. Its not saving so it shouldnt actually be a problem. it does look a little weird, but if it functions the same as other acumatica screens then it shouldnt be a problem.

2 replies

Forum|alt.badge.img+2

Hello ​@justen0351 I want ask that ProtoCutLine is this your header DAC ?
if not then replace your header DAC & try.

you can try like this :

protected void _(Events.RowSelected<ProtoCut> e)
{
var row = e.Row;
if (row == null) return;

var details = SelectFrom<ProtoCutLine>
.Where<ProtoCutLine.orderID.IsEqual<ProtoCut.orderID.FromCurrent>>
.View.Select(this)
.RowCast<ProtoCutLine>();

bool invalid =
details.Any(d => d.StkRepType == "M" && string.IsNullOrEmpty(d.BarID));

row.HasInvalidLines = invalid;

RemoveHold.SetEnabled(!invalid);
ReleaseFromHold.SetEnabled(!invalid);
}

I hope it helps.


Forum|alt.badge.img
  • Author
  • Varsity III
  • Answer
  • December 3, 2025

@Abhishek Niikam thanks for the response. I really appreciate it. I looked at the sales order screen and mine is functioning the say way that it is so i am just going to leave it as is. Its not saving so it shouldnt actually be a problem. it does look a little weird, but if it functions the same as other acumatica screens then it shouldnt be a problem.