About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Technical Blog Post
Abstract
How do I programmatically pre-fill some case property values on a case add page?
Body
Here's a slight twist on a previous entry where I showed how to
dynamically add choice values to an Add Task page. For this one, we want to pre-fill some case properties on Add Case page and set one of the property fields to be read only. Here's how:
- Add a Scrip Adapter widget to your Add Case page and rename it "Prefill"
- Wire the Page Container's Send New Case Information event to the inbound event on your Prefill Script Adapter
- Add the following script to your Script Adapter, replacing the property name with one from your solution
/* Requires ICM 5.2.0.1 */ console.log(this.name,": ",payload); require(["icm/base/Constants", "icm/model/properties/controller/ControllerManager"], function(Constants, ControllerManager) { /* Get the coordination and editable objects from the event payload. */ var solutionPrefix = payload.caseType.getSolution().getPrefix(); var coordination = payload.coordination; var editable = payload.caseEditable; /* Change me to your property name */ var theProperty = solutionPrefix + "_CaseStage"; /* Use the LOADWIDGET coordination topic handler to obtain the controller binding */ /* for the editable and to update the properties. */ coordination.participate(Constants.CoordTopic.LOADWIDGET, function(context, complete, abort) { /* Obtain the controller binding for the editable. */ var collectionController = ControllerManager.bind(editable); /* Start a batch of changes. */ collectionController.beginChangeSet(); /* Make the updates to the properties. */ collectionController.getPropertyController(theProperty).set("value", "0"); collectionController.getPropertyController(theProperty).set("readOnly", true); /* Complete a batch of changes. This tells all subscribed widgets to refresh. */ collectionController.endChangeSet(); /* Call the coordination completion method. */ complete(); }); /* Use the AFTERLOADWIDGET coordination topic handler to release the controller binding for the editable. */ coordination.participate(Constants.CoordTopic.AFTERLOADWIDGET, function(context, complete, abort) { /* Release the controller binding for the editable. */ ControllerManager.unbind(editable); /* Call the coordination completion method. */ complete(); }); });
[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSCTJ4","label":"IBM Case Manager"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]
UID
ibm11281280