Skip to main content
Answer

Workflow Event Handler Errors

  • November 21, 2024
  • 1 reply
  • 88 views

Forum|alt.badge.img+8

Hello guys,

 

I am having an issue with a workflow event handler:

Workflow declaration:

.WithHandlers(handlers =>
{
handlers.Add(handler => handler
.WithTargetOf<ARBalances>()
.OfEntityEvent<ARBalancesCreditHoldExt.MyEvents>(e => e.CreditLimitViolated)
.Is<SOShipmentEntryCreditHoldExt>(g=> g.OnCreditLimitViolated)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>.
Where<SOShipment.customerID.IsEqual<ARBalances.customerID.FromCurrent>>>()
);
handlers.Add(handler => handler
.WithTargetOf<ARBalances>()
.OfEntityEvent<ARBalancesCreditHoldExt.MyEvents>(e => e.CreditLimitSatisfied)
.Is<SOShipmentEntryCreditHoldExt>(g => g.OnCreditLimitSatisfied)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>.
Where<SOShipment.customerID.IsEqual<ARBalances.customerID.FromCurrent>>>()
);
})

//Add to State
lowStates.Update<SOShipmentStatus.open>(flowState =>
{
return flowState
.WithActions(actions=>
actions.Add(productionConfirm, c=>
c.WithConnotation(ActionConnotation.Secondary)))
.WithEventHandlers(handlers=>
{
handlers.Add<SOShipmentEntryCreditHoldExt>(g =>
g.OnCreditLimitSatisfied); //CS0029 -
//Error (active) CS0029 Cannot implicitly convert type //'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment, //PX.Objects.AR.ARBalances>' to //'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment>'

handlers.Add<SOShipmentEntryCreditHoldExt>(g=>
g.OnCreditLimitViolated); //CS0029 -
//Error (active) CS0029 Cannot implicitly convert type //'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment, //PX.Objects.AR.ARBalances>' to //'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment>'
});
});
//Graph PXWorkflowEventHandler
public class SOShipmentEntryCreditHoldExt : PXGraphExtension<SOShipmentEntry>
{
// other logic

public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitViolated;
public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitSatisfied;
}

//DAC Workflow Event
public class ARBalancesCreditHoldExt : PXCacheExtension<ARBalances>
{
public class MyEvents : PXEntityEvent<ARBalances>.Container<MyEvents>
{
public PXEntityEvent<ARBalances> CreditLimitViolated;
public PXEntityEvent<ARBalances> CreditLimitSatisfied;
}
}

If I change the PXWorkflowEventHandler to just 

public PXWorkflowEventHandler<SOShipment> OnCreditLimitViolated;

      public PXWorkflowEventHandler<SOShipment> OnCreditLimitSatisfied;

The .WithHandlers declaration of the handler throws this error:

Severity    Code    Description    Project    File    Line    Suppression State    Details
Error (active)    CS0029    Cannot implicitly convert type 'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment>' to 'PX.Data.WorkflowAPI.PXWorkflowEventHandler<PX.Objects.SO.SOShipment, PX.Objects.AR.ARBalances>'    NCRLog    C:\Acumatica ERP\Acu\App_Data\Projects\NCRLog\NCRLog\Workflow\SOShipmentEntry_WorkflowExt.cs    210        
 

I can tell i am doing something fundamentally wrong, but I have no clue what it could be, could anyone offer some help?

Best answer by aiwan

Not too sure if this is right, but I changed extended the SOShipment DAC to contain the MyEvents class as follows:

 public class SOShipmentCreditHold : PXCacheExtension<SOShipment>
{
public class MyEvents : PXEntityEvent<SOShipment>.Container<MyEvents>
{
public PXEntityEvent<SOShipment> CreditLimitViolated;
public PXEntityEvent<SOShipment> CreditLimitSatisfied;
}

}

and updated my workflow event declaration as follows:

.WithHandlers(handlers =>
{
handlers.Add(handler => handler
.WithTargetOf<SOShipment>()
.OfEntityEvent<SOShipmentCreditHold.MyEvents>(e => e.CreditLimitViolated)
.Is<SOShipmentEntryCreditHoldExt>(g=> g.OnCreditLimitViolated)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>>()
);
handlers.Add(handler => handler
.WithTargetOf<SOShipment>()
.OfEntityEvent<SOShipmentCreditHold.MyEvents>(e => e.CreditLimitSatisfied)
.Is<SOShipmentEntryCreditHoldExt>(g => g.OnCreditLimitSatisfied)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>>()
);
})

This is my PXWorkflowEventHandler in the graph:

public class SOShipmentEntryCreditHoldExt : PXGraphExtension<SOShipmentEntry>
{
// other logic

public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitViolated;
public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitSatisfied;
}

This fires as I expect them too.

1 reply

Forum|alt.badge.img+8
  • Author
  • Captain II
  • Answer
  • November 21, 2024

Not too sure if this is right, but I changed extended the SOShipment DAC to contain the MyEvents class as follows:

 public class SOShipmentCreditHold : PXCacheExtension<SOShipment>
{
public class MyEvents : PXEntityEvent<SOShipment>.Container<MyEvents>
{
public PXEntityEvent<SOShipment> CreditLimitViolated;
public PXEntityEvent<SOShipment> CreditLimitSatisfied;
}

}

and updated my workflow event declaration as follows:

.WithHandlers(handlers =>
{
handlers.Add(handler => handler
.WithTargetOf<SOShipment>()
.OfEntityEvent<SOShipmentCreditHold.MyEvents>(e => e.CreditLimitViolated)
.Is<SOShipmentEntryCreditHoldExt>(g=> g.OnCreditLimitViolated)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>>()
);
handlers.Add(handler => handler
.WithTargetOf<SOShipment>()
.OfEntityEvent<SOShipmentCreditHold.MyEvents>(e => e.CreditLimitSatisfied)
.Is<SOShipmentEntryCreditHoldExt>(g => g.OnCreditLimitSatisfied)
.UsesPrimaryEntityGetter<
SelectFrom<SOShipment>>()
);
})

This is my PXWorkflowEventHandler in the graph:

public class SOShipmentEntryCreditHoldExt : PXGraphExtension<SOShipmentEntry>
{
// other logic

public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitViolated;
public PXWorkflowEventHandler<SOShipment, ARBalances> OnCreditLimitSatisfied;
}

This fires as I expect them too.