I have following scenario that i have done in legacy platform v 6.x:
@Subscribe("scheduleMeetBtn")
public void onScheduleMeetBtnClick(Button.ClickEvent event) {
if(PersistenceHelper.isNew(getEditedEntity())){
notifications.create(Notifications.NotificationType.HUMANIZED)
.withCaption("SELECT")
.withDescription("Please Save the Sales Opportunity before setting a meeting")
.show();
}else {
CalendarTaskEvent calendarTaskEvent = metadata.create(CalendarTaskEvent.class);
calendarTaskEvent.setEventGroup(EventGroup.CRM);
calendarTaskEvent.setEventCategory(EventCategory.MEETING);
calendarTaskEvent.setTaskStatus(TaskStatus.PLAN);
if(getEditedEntity().getLeadFrom().equals(LeadFrom.CUSTOMER)) {
calendarTaskEvent.setCustomer(getEditedEntity().getCustomerProfile().getName());
calendarTaskEvent.setCustomerProfile(getEditedEntity().getCustomerProfile());
}else{
calendarTaskEvent.setCustomer(getEditedEntity().getProspect().getName());
calendarTaskEvent.setProspect(getEditedEntity().getProspect());
}
calendarTaskEvent.setSalesOpportunity(getEditedEntity());
openEditor(calendarTaskEvent, WindowManager.OpenType.DIALOG, ParamsMap.of("hideEventGroup", "yes")).addCloseWithCommitListener(() -> salesOpportunityDs.refresh());
}
}
As you may have noticed “openEditor(…” has -
(1) Parameter sent which is not any Entity element rather just a simple parameter value sent to the editor screen to control the behavior of the editor screen
(2) .addCloseWithCommitListener(() : that refreshes the screen data aftert the editor has committed the entry
In Platform V7.x I tried in the following way:
screenBuilders.editor(calendarTaskEventsGrid)
.newEntity()
.withInitializer(task -> { // lambda to initialize new instance
task.setName("New customer");
})
.withScreenClass(CalendarTaskEventEdit.class) // specific editor screen
.withLaunchMode(OpenMode.DIALOG) // open as modal dialog
.build()
.show();
But “task.setName(“New customer”);” seems not appropriate to use (desn’t recognize). More importantly, what is right way to use ".addCloseWithCommitListener(()?
How can we do the #1 & #2 in V7 as mentioned above?