Skip to main content
Solved

Add new status value and set enable


Forum|alt.badge.img

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

Best answer by Naveen Boga

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.
View original
Did this topic help you find an answer to your question?

13 replies

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 253 replies
  • May 18, 2023
mrthanhkhoi wrote:

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/


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • Answer
  • May 19, 2023

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.

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • May 24, 2023

 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


dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • 648 replies
  • May 24, 2023

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. 

 


darylbowman
Captain II
Forum|alt.badge.img+13

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));

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • June 2, 2023

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?


darylbowman
Captain II
Forum|alt.badge.img+13

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


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • June 2, 2023

Hello @darylbowman, it show Archive on entry screen

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • June 6, 2023

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


darylbowman
Captain II
Forum|alt.badge.img+13

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.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • June 15, 2023

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.


darylbowman
Captain II
Forum|alt.badge.img+13

Nicely done. Glad you figured it out.


dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • 648 replies
  • June 15, 2023

@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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings