Discussion


Pegasystems Inc.
IN
Last activity: 6 Mar 2025 3:44 EST
How to launch flow action or view in a modal in Constellation application : A custom approach
This document captures the steps required to launch flow action or view in modal dialog in Constellation application, this is a custom dx component approach.
Note: Before using this approach, hope explored all possible ways to solve this usecase using OOTB configuration.
Editing data object
In order to do update on data objects, do follow the below article:
You can replace Operator class with any other data class, infrastructure remains the same.
Reading data object via flow action
Steps:
1. Open app studio and create and configure a view eq., UpdateDetailsAction1
2. Switch to Dev studio and create a flow action under data object class and configure above View eq., UpdateDetailsAction1.
3. Create a single page type datapage, this is used to build context (step page) to execute flowaction/view.
4. Write a custom component to launch modal.
References:
Sample gallery: https://github.com/pegasystems/constellation-ui-gallery
Sample code
import { Button, Modal, useModalManager, useModalContext } from '@pega/cosmos-react-core';
export default function ViewInModal(props) {
const { getPConnect } = props;
const pConnect = getPConnect();
const { create } = useModalManager();
const { dismiss } = useModalContext();
const onResponse = async (data) => {
const { fetchViewResources, updateViewResources } = PCore.getViewResources();
// Update metadata store
await updateViewResources(data);
// Update redux with data.
pConnect.updateState(data.data);
// Root view
const viewName = data.uiResources.root.config.name;
// Build config to create new pconnect object
const viewConfig = {
meta: fetchViewResources(viewName, getPConnect()),
options: {
context: getPConnect().getContextName(),
pageReference: 'dataInfo.content',
isFlowContainer: '',
parentPageReference: ''
}
};
const { getPConnect: newPConnect } = PCore.createPConnect(viewConfig);
// Create view component.
const viewElement = newPConnect().createComponent(viewConfig.meta);
// Model rendering
const modal = () => {
return (
<Modal heading='List of cases' autoWidth enter>
{viewElement}
</Modal>
);
};
create(modal, { closeInitialModal: dismiss }, { dismissible: true });
};
const itemClick = () => {
// Get row prop value
const id = getPConnect().getValue('.ID');
// Rest api to open flow action, define single datapage type under "data_view_ID" payload
// to load the record before processing, this will become context to view.
// action_ID is the flow action name.
// Pass parameters as part of body.
PCore.getRestClient()
.invokeRestApi('openDataObjectAction', {
queryPayload: {
data_view_ID: 'D_TestData',
action_ID: 'TestFA'
},
body: { dataViewParameters: { ID: id } }
}, getPConnect().getContextName())
.then((data) => {
onResponse(data.data);
});
};
return (
<Button variant='link' icon compact={false} onClick={itemClick}>
Modal
</Button>
);
}
Code explaination
5. Add custom dx component to view.
Reference: https://github.com/pegasystems/constellation-ui-gallery
OR
In case custom component required to be part of ListView table then do follow below article:
-
Reply
-
Sri Sowmya Medicharla -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!


Areteans Technology Solutions Australia
AU
@baipcI am trying to use the above code, and I can see errors. Some of the functions require few mandatory parameters to be passed. How did you bypass these?
fetchViewResources - requires ClassID
createComponent - requires data source and additional properties
invokeRestApi - missing context
Thanks Acquil


Pegasystems Inc.
IN
@Acquil All required information can be accessed through pConnect APIs,
For classID: pConnect.getValue(".classID")
createComponent: pass as empty object.
invokeRestApi: pConnect.getContextName()


Areteans Technology Solutions Australia
AU
@baipc Thanks for your reply.
I am able to fix the compilation issues but now when I publish the component, below error is seen, even though the module is present in my workspace. Can you please suggest a fix for this? any update to be done to tsconfig.json?
Error... Can't resolve '@pega/pcore-pconnect-typedefs/rest-client' in '*********\src\components\Ee_Extensions_LaunchAction'


Pegasystems Inc.
IN
@Sandeep_Ghosh We are working on different experience/approach to address this kind of usecase, in future releases you will see better/best OOTB.


Pegasystems Inc.
IN
@Rajashekar Reddy CH You can use if context is a casetype, for datatype it will not work.


Evonsys Pvt Ltd
LK
In the code, "openDataObjectAction" means an API that should be built according to out requirement right?


Pegasystems Inc.
IN
@SameeraS openDataObjectAction is OOTB action, it takes flowaction id as a parameter so you can do custom logic in flowaction.


Evonsys Pvt Ltd
LK
Can you please guide me understand more about "openDataObjectAction". What did you mean by OOTB Action?


Evonsys Pvt Ltd
LK


Pegasystems Inc.
IN
@SameeraS This is CoreJS apis. https://docs.pega.com/bundle/constellation-dx-components/page/constellation-dx-components/custom-components/dxcb-using-pcore-pconnect-public-apis.html
Updated: 25 Feb 2025 7:58 EST


BlueRose Technologies
IN
@baipc Thanks for posting on this topic. As per your suggestion, I'm trying to create a component and using the above mentioned code. But I'm getting error on calling API createComponent that all the required data source and additional properties are not passed. As you mentioned in the previous comment, I tried passing as empty object but still error persists. PFB the screenshot of the same. It will be really helpful if you could share the right snytax or arugments for the createComponent to be called in the context.


Pegasystems Inc.
IN
@Connect@Abicom This is typescript error, please ignore. @ghosa4 How to disable it?


BlueRose Technologies
IN
@baipc @ghosa4 Thanks for the prompt response. What do you meant by ignore. Despite this compile time error, I tried publishing the component now but it fails while generating the build. PFB the screenshot of the same. I'm unable to test this component within Pega portal due to this issue.
Assistance on this solving this issue will be really helpful and greatly appreciated.


Pegasystems Inc.
IN
@Connect@Abicom Kindly try using the following syntax:
const viewElement = newPConnect().createComponent(viewConfig.meta, "", 0, {});
We will also address this in the upcoming release to make these arguments optional.


BlueRose Technologies
IN
@ghosa4 @baipc I really appreciate your quick help. I'm able to use the shared syntax and launch the flow action of a data type successfully in the Pega Constellation portal. Also, please note that I was getting undefined error for props and data params passed to the function as part of the component code which I fixed by defining it as type any as mentioned below. Hope this is the right way of fixing the error.
i.e. const onResponse = async (data:any) export default function ViewInModal(props:any)


BlueRose Technologies
IN
@baipcI'm able to launch the flow action and see the view in a modal window but flow action buttons are not available. I believe this approach can be followed to show a readonly data using a data page context. But I can't do any action apart from close. PFB the screenshot of the same.