Preprocessing rules on submission in constellation

In a Pega Constellation application, we are cloning a Parent Job case (BR-Disclosure-Work-Job) from a Work Order table context (BR-Disclosure-Work-WorkOrder) via association.

To satisfy a business requirement, we create the cloned case inside the Flow Action Pre-Processing Activity so we can pass the NewlyClonedJobID property as a parameter to a Data Page and render the newly generated Case ID in the modal view before the user clicks Submit.

However, in Constellation, when the user submits the modal, the Flow Action’s pre-processing activity executes again before post-processing runs. This triggers second time, resulting in duplicate case creation errors.

  • Primary Context: Work Order table view (BR-Disclosure-Work-WorkOrder).

  • Target Case: Parent Job case (BR-Disclosure-Work-Job) linked via association.

  • Pre-Processing Logic: Executes pxCreateTopCase to generate the cloned Job case and we obtains the generated pyID / pzInsKey passing NewlyClonedJobID as a parameter to a Data Page to display the newly cloned Job ID directly in the modal view.

When the user completes the modal and clicks Submit, Constellation’s execution re-evaluates the Flow Action and runs the Pre-Processing Activity a second time before proceeding to post-processing. Because the activity executes again, it attempts to recreate the cloned case, causing duplicate database key / primary key insert failures.

Attempted Solutions:

Obj-Browse Database Checks:

  • Attempted querying the database in Step 1 of the activity to check if the cloned Job already exists before executing pxCreateTopCase.

System Clipboard Flags (pxThread / pxRequestor):

  • Attempted setting clipboard properties on pxThread or pxRequestor to track whether the clone was already generated. Constellation’s stateless REST API submission flushes/resets transient clipboard pages and parameters across the submit boundary.

Editable Data Page (Requestor Scope):

  • Attempted storing NewlyClonedJobID in an Editable, Requestor-scoped Data Page (D_Page) to use as a guard condition (Exit Activity if D_Page.pyID is not blank). The DX API submission context flushes/re-initializes the Data Page state during the form submit API call, resetting the property to blank and failing the guard check.

I understand preprocessing is for initializing the values , but as per our business needs, we are ought a solution for this.

As per the business, to avoid many clicks on the screen, we need to create a new case on the pre-processing itself and we do not want to do it post processing and do not want a have a full component for this. What is the recommended Pega Constellation design pattern to handle case creation during modal launch when the newly cloned Case ID must be generated, passed via Data Page parameter, and displayed in the view prior to submission?

@MarcCheong - any thoughts on this?

@GokulS55 check out this doc, item 3 “The pre-processing rule defined in the action identified by the actionID parameter is again run on refresh and submit, prior to the request body being merged in. Pre-processing logic should only be used to provide default values of fields.”

I remember seeing a tip from @RonaldDeLignie early days of Constellation (8.8 maybe 8.7) watching out for this. Long before Constellation 101 became into existence.

Alternatives

If extra clicks are the worry, why have an assignment in the action at all?

At run time, it just creates the clone case - why have confirmation at all?

Rudimentary example, but you can clean the UX up by putting the “cloned from case” in the summary panel, having a conditional case type shown if cloned etc. etc.

User Experience: Don’t navigate to the case

Put an assignment after but that does create an assignment that needs extra clicks..

Hi @MarcCheong ,

We are trying to modernize our current application from theme cosmos to constellation. Currently, we tried to give the case wide optional action, so it does come in the landing page three Dot icon. If we try it with a process in the optional actions, the optional action does not come in the landing page. So, we are using the normal assignment and trying to create it in the pre-processing.

I also understand it is also the same clicks to open the case and proceed with the optional action but in their theme cosmos application, they did have a button to clone the case in the landing page, so we are also trying to achieve the functionality through landing page in constellation.

I see. Yes, optional processes don’t work in this context (I have raised feedback for this, as really they should FDBK-146067).

List View Context: No great options?

  1. It’s clear you can not use pre-processing, it will re-run no matter what you do.
    1. Perhaps you could do a duplicate check to stop the creation again
  2. If you are using a list view context, then that post processing, wouldn’t work either because we don’t navigate to the case after we process the action.
    1. So the UX need for confirmation would not be met.

Or users should not use that screen to clone - they should open the case to clone?

Wondering if others in the ecosystem have some ideas here.

Hi @MarcCheong ,

Thank you for your suggestion. We have tried to go with a separate component for the clone job where we are calling the flow action. And on the click of the button, it will open and close the popup automatically and replace the current window with the newly created case. The flow action to be accessible for the button, we have called it in the case wide local actions. The option is set to be visible on both the button and three dot menu. We try to conditionalize the visibility of the case wide local action to “Never” to make it not displayed in the three-dot icon and but also accessible for the button. But if we make it as never or conditionalize, the button is not working and throwing an error as " (Flow Action Name) is not a valid action to use".

Why does constellation take “Never” visibility as like a no privilege and throwing this error. Is there any suggestions or recommended solutions for this would be helpful.

If I understand correctly, you are trying to hide an action but also execute it. The error message you see would be expected - a user can’t execute an action if that action isn’t valid.

We see the same with read only fields an Form Refresh Settings > users can’t update read only fields. DX API blocks them. I’m not aware of any way to get around that.

Perhaps someone else in the community knows?

However, what would be the harm in leaving the action in the list? User can execute it manually or via your custom button?