Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Replaced 'cbx' prefixed events with Canvas Constants.

...

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
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) 
    {

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

      /* ct.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(['BBRANCH_NAME'],data.BRANCH_NAME);
         fm.model.setValue(['PAYMENT_TYPE'],data.PAYMENT_TYPE);

      });

    });

  }

});

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

...