Solved

Add new status value and set enable


Userlevel 3
Badge

Hello,

I want to create new status value “Archive” to screen Invoices and Memo and enable this field when the status is Open so that End-User could change status to “Archive”

I tried add new status value as instruction in topics 

 

and use following code to enable Status field

using PX.Data;


namespace PX.Objects.AR
{
public class ARInvoiceEntry_Extension : PXGraphExtension<PX.Objects.AR.ARInvoiceEntry>
{
#region Event Handlers

protected void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ARInvoice)e.Row;
if (row != null)
{
PXUIFieldAttribute.SetEnabled<ARInvoice.status>(cache, row, true);
}
}

#endregion
}
}

However, I can’t find new value in list dropdown values

and fields Status is still disable

Could you please help me?

 

Regards,

Khoi

icon

Best answer by Naveen Boga 19 May 2023, 07:21

View original

13 replies

Userlevel 7
Badge +12

@mrthanhkhoi Good news sorry yes i would have created a new workflow by extending the default system worflow but i would have done that in the package

Badge +11

Nicely done. Glad you figured it out.

Userlevel 3
Badge

Hello @darylbowman, I found solution to resolve the issue on GI.

We need to extend the Graph to overwrite existing customization of default field Status.

You could find the details in the topic 

 

@dcomerford  for your information: My Workflow is created based on a system workflow so I need to creating new status by extending the default workflow (by coding) them I add new status in my workflow. It means I need to do both coding and configuration.

 

Thank you very much for your help.

Badge +11

I’m sorry, I don’t. I also have no experience adding additional statuses. I’ve added countless Reasons to Cases, but no Statuses. If it’s showing on the document, I have no clue why it wouldn’t be showing in the GI.

Userlevel 3
Badge

Does anyone have idea why the status didn’t show in Generic Inquire screen? :(

Userlevel 3
Badge

Hello @darylbowman, it show Archive on entry screen

 

Badge +11

Could you update us on the way that you chose to do it? Does it correctly show as 'Archive' on the Invoice entry screen?

Userlevel 3
Badge

I am able to create the new status and switch value between them.

However, I dont know why the value of status field on Generic Inquiry (screen AR3010PL) are empty. It should have status = Archive. 

Do you have any idea?

Badge +11

In order to move from one Status to another, you need to define a transition. It looks like you tried to add one, but I don’t believe it’s configured quite right.

Here’s an example of a transition that is working in my code:

transitions.Add(transition => transition
.From(States.Open)
.To(States.PendingCustomer)
.IsTriggeredOn(actionWaitForInfo));

 

 

Userlevel 7
Badge +12

You could always do this without code. Copy the default workflow for the screen and then add the New State in there. Then create a new action to set this state and then add it to the Action on the Open State. I have done something similiar for other forms with out any ‘code’ needed. 

 

Userlevel 3
Badge

 Hello @Naveen Boga  and @RohitRattan88 . Thanks for your suggestion, I tried to add new Status by implement a workflow as following:

using PX.Common;
using PX.Data;
using PX.Data.BQL;
using PX.Data.WorkflowAPI;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CS;
using PX.Objects.SO;
using System.Collections;
using System.Collections.Generic;
using static PX.Data.WorkflowAPI.BoundedTo<PX.Objects.AR.ARInvoiceEntry,
PX.Objects.AR.ARInvoice>;

namespace PX.Objects.AR
{
public class ARInvoiceArchive_Workflow : PXGraphExtension<ARInvoiceEntry_Workflow, ARInvoiceEntry>
{

public override void Configure(PXScreenConfiguration config)
{
Configure(config.GetScreenConfigurationContext<ARInvoiceEntry, ARInvoice>());
}
protected virtual void Configure(WorkflowContext<ARInvoiceEntry,
ARInvoice> context)
{


var processingCate = context.Categories.Get("Processing");
var newAction = context.ActionDefinitions
.CreateNew("Archive", a => a
.DisplayName("Archive")
.WithCategory(processingCate)
);



context.UpdateScreenConfigurationFor(screen => screen
.UpdateDefaultFlow(flow =>
{
return flow
.WithFlowStates(flowStates =>
{
flowStates.Update<ARDocStatus.open>(flowState =>
{
return flowState.WithActions(actions =>
actions.Add(newAction));
});
flowStates.Add<ARDocStatus_Archive.archive>(flowState =>
{
return flowState.WithActions(actions =>
actions.Add(newAction, a => a
.IsDuplicatedInToolbar()
.WithConnotation(ActionConnotation.Success)));
});
})
.WithTransitions(transitions =>
{
transitions.AddGroupFrom<ARDocStatus_Archive.archive>(ts =>
{
ts.Add(t => t
.ToNext()
.IsTriggeredOn(newAction)
.WithFieldAssignments(fass => fass
.Add<ARInvoice.docDesc>(f => f.SetFromValue("test workflow"))));
});
});
})

.WithFieldStates(fs =>
{
fs.Add<ARInvoice.status>(state =>
state.SetComboValue(ARDocStatus_Archive.Archive, "Archive"));
})
.WithActions(actions =>
{
actions.Add(newAction);
})
);
}
}

public class ARDocStatus_Archive : ARDocStatus
{
public const string Archive = "A";
public class archive : BqlType<IBqlString, string>.Constant<archive>
{
public archive()
: base("A")
{
}
}
}
}

When status is Open, the button Archive is display but when I click on it, the status doesn’t change  to “Archive”.

Could you please have look and give me a suggestion?

 

Thank you in advance

Userlevel 7
Badge +17

Hi, @mrthanhkhoi  Adding a new status is not enough to change the status and it might not work because you need to define a Workflow when the status should move to the new status.

  •  Create a new workflow by inheriting the existing workflow
  • Create a state and transitions if required.
  • define, when the status is moved to new status.
Userlevel 7
Badge +4

enable this field when the status is Open so that End-User could change status to “Archive”

Not sure if this is the correct approach.

Maybe look into workflows and changing document status using workflows

Refer to T270 for guidance: https://openuni.acumatica.com/courses/development/t270-workflow-api/

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved