Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Consider the following apps added for the beneficiary module in payments. When a beneficiary record in the Beneficiary Details app on the left is clicked, those beneficiary details are displayed on the Beneficiary Details Form on the right.

Image RemovedImage Added


Step 1:

The following is the sample code for triggering the broadcast event. In our example, this code must be written in the listener JS file for the Beneficiary Details app:

Code Block
languagejs
CWEH.registerHandler('WGT_BENE', CWEC.ROW_CLICK, function(config, data) 
{
  ctcanvas.MessageBus.publish("BENEFICIARY_SELECTED", data);
});

/* Here, 
1. WGT_BENE is the widget ID for Beneficiary Details app.
2. CWEC.ROW_CLICK is the API for capturing row click event in the Beneficiary Details app.
3. ctcanvas.MessageBus.publish is the function to trigger the broadcast event.
4. BENEFICIARY_SELECTED is the event ID for broadcast event.
*/

...

Code Block
languagejs
canvas.ns("canvas.form.listeners");

canvas.form.listeners.formComponents = Class(canvas.Observable, 
{
  constructor: function(config) 
  {
    this.fm = config.fm;
  },
  
  registerHandlers: function() 
  {

    this.fm.registerHandler("cbxpostformrender"CFEC.POST_FORM_RENDERER, function(fm, event, fieldName,value) 
    {

      ctcanvas.MessageBus.subscribe('BENEFICIARY_SELECTED', "NAMESPACE", '', function(data, eventName) 

      /* ctcanvas.MessageBus.subscribe is the function to subscribe for broadcast events of other apps.
	  *  Here, the Beneficiary Details Form app is subscribing to the ‘BENEFICIARY_SELECTED’ 
      *  broadcast event from Beneficiary Details app. The data received from broadcast event 
      *  is populated to the fields on the Beneficiary Details Form app. */

      {      
         /* The data received from broadcast event is populated to the fields on 
		 *  the Beneficiary Details Form app. */
         fm.model.setValue(['BENE_NAME'],data.BENE_NAME);
         fm.model.setValue(['BENE_ACC_NO'],data.BENE_ACC_NO);
         fm.model.setValue(['BANK_NAME'],data.BANK_NAME);
         fm.model.setValue(['BBRANCHBRANCH_NAME'],data.BRANCH_NAME);
         fm.model.setValue(['PAYMENT_TYPE'],data.PAYMENT_TYPE);

      });

    });

  }

});

CFLR.registerListener("TEST_INTERAPPBENE_DETAILS_FORM_APP", canvas.form.listeners.formComponents);

...