Create pop-up screen SAP C4C
Hi!
In this post I’d like to tell you how to create a pop-up modal dialog window in SAP Cloud Application Studio. This window must appear after pressing “Save” button when a number of conditions are met.
Scenario.
I had a requirement to create a modal dialog window which pops up in Lead when it has status “Qualified”.
On this window a button “Convert to opportunity” should be placed. By pressing this button a standard screen for converting lead to opportunity should appear.
Realisation.
First of all we need to catch a moment when conditions are met. In my case I need to catch a moment when status “Qualified” is set in Lead.
To do this we need to create an extension object for Lead.
Here we add field “ConvertLead” with type Indicator. So if all conditions are met we set this indicator to true in Lead – Before-Save.
Now we need to create embedded component and add it to TI screen of Lead.
Then we need to configure DataList: add parameters ID and ConvertLead and bind them.
Next step we need to create InPort in EC for field LeadID. For this field we need to create structure in DataList and add parameter LeadID in it.
We use this parameter as key for reading Lead instance.
Then add handler for InPort. This handler will be used for retrieving current LeanLead.
Next step we configure field CreateLead in DataList. Add EventHandler for checking this field in the case it changes.
EventHandler looks like this:
EventHandler checks if we should open ModalDialog screen. We use Condition to check if indicator CreateLead is set. In the case if indicator is set we open ModalDialog.
Now we need to configure ModalDialog screen: add button for converting LeanLead to opportunity. To add button you should drag and drop it from Toolbox tab.
Then create outport for button (settings of it shown on picture):
Next step add structure for ThingType navigation and add field LeanLeadID_OPP, change CCTS Type to identifier, change ThingType Mode to static and set Associated ThingType.
Now configure button: change semantic to QuickCreate(this must be the first thing you do), add associated ThingType container, OutPort and write InPort.
All settings have been done. Now we need to attach EC to /BYD_COD/SalesOnDemand/Marketing/Prospect/COD_Mkt_Prospect.TI.uicomponent (in my case).
Choose your EC.
Bind parameters (OutPort in TI and InPort in EC, LeadID).
Click Apply and test.
Result.
Create Lead.
Change status to Qualified and press Save button.
ModalDialog should appear. Click button Opportunity on ModalDialog and convert lead to opportunity.
Check conversion result.
Hope my post will be helpful!
Have a good day!
Thank you Andrey for sharing this information!
Best regards.
Hi, Andrey
Thank you very much for showing how to create pop-up screen!
Great blog ! Thank you.
Is it possible to use the OK button click event from the Modal dialog ? Is their any std. even already associated with OK button that appears on Modal Dialog ?
Hello!
Yes, you can use event on OK button and add custom events which you want. By default on OK button only close event is set.
Best regards!
Awesome ! Thanks Andrey 🙂
Hi Andrey,
Thanks for the nice blog!
I have the similar requirement and followed your approach.
In Lead object, when the Status is Qualified and Category is Residential, I need to give a popup after clicking on Save button. I need to get the popup without actually saving the transaction as I need to enter two values on the popup. But, it is saving the Lead and then giving the pop-up (You can see "Your Entries have been saved") message on the popup.
If I write any validation to stop saving the Lead, popup is not getting opened. Could you please let me know if it possible to open a popup without saving the Lead object and if so, how could it be done.
Regards,
Chandra Kishore.
Andrew described a solution for a "after-save" popup.
Highelvel: You want a popup "before-save" so you can consider to dynamically show these two fields during data input by enduser (instead of popup). Show two fields after a roundtrip instead of trying to highjack the save button.
Detail: So you'll have a myFieldsVisibleIndicator that is set to true in after-modify (if qualified and category mets your criteria or to false if user changed category again). Hint: Once the myFieldsVisibleIndicator is saved with true on database you should not change it anymore back to false to avoid having "ghost data" by hinding the fields; this can be done either via getFromDB call or via another (transient) field holding the state at afterLoading-event
myField1 and myField2 will be bound to myFieldsVisibleIndicator via UIDesigner/Ext. Explorer/Adjust Properties/visibility
once myFieldsVisibleIndicator it is true and a server-side roundtrip is triggered the fields will be shown.
then you can use the validate and avoid the save if invalid selections or mandatory data in myField1 & myField2 -> these approach makes it also possible to have same logic independent of frontend or odata usage.
finally, if one of the event fields qualified/category does not trigger a roundtrip you can either request that from SAP (influence board ;)) or create custom fields with same datatype - custom fields always trigger the after-modify.
Hi Andrey,
Thank you so much for this informative and very helpful block!
I recently tried to implement something similar in the Visit object - but failed.
I' ve described my approach in detail here: https://answers.sap.com/questions/13396432/trying-to-create-popup-in-visit.html
Can you provide any further help in this regard?
Thanks and kind Regards,
Anna
Hi Andrey,
Thanks for the nice blog.
I have tried the similar requirement on Opportunity for creating Sales Quote. It is working fine and when I click on pop up button, Quote TI screen gets open in new window.
Currently user needs to go back to opportunity to close the pop up, is there any possibility to close the pop up automatically after clicking on Create Quote button on pop up? Currently "Create Quote" button on pop up has semantic as "QuickCreate", along with this I have tried to add on click event "Close" (Window Operation -> Close) but it is not working.
Thanks,
Pawan
Hello Andrey
I have tried similar process on Ticket object but got failed.
Popup is not opening on clicking on save but its opening when I click on EC.
Can you provide any further help in this ?
Thank You,
Asfiya