Calculated Field not populating from Related Module

Hello everyone,

Using SugarCRM Professional, v7.2.2.1

I have two custom modules and am trying to populate fields on the first module (KGSProject) when I relate a record of the second module (DeploymentSurveys). Using the built-in formula builder in Module Builder, I create a calculated field on KGSProject field like so (formula created through prompts, not hand-typed): 



However, when I relate a DeploymentSurvey to a KGSProject, the calculated field does not populate and remains blank. 

I've tried saving and resaving, redeploying the modules, even executing a Mass Update and Recalculate Values on the KGSProjects Module list. I can't seem to get the field on KGSProjects to populate from the related field on DeploymentSurveys. The related field on the related DeploymentSurvey is definitely populated with text, it's not blank and should be returning a Submitter's Name on KGSProjects.

Is there something I am missing? It seems like this should be very straightforward, but it's not producing results.

Regards,
Stephen
Parents
  • Hi Stephan,

    You can extend the create.js, create a function that triggers every time there is a change on the view. Through the js code you can pull the value of the related record. Something like this:

    ({
    extendsFrom: 'CreateView',

    initialize: function(options) {
    this._super("initialize", [options]);
    this._populateFields();
    this.model.on('change:assigned_user_id', this._populateFields,this);
    },

    _populateFields: function() {

    var self = this;

    var userBean = app.data.createBean('Users', {id:self.model.get("assigned_user_id")});
    var branch_user;

    var request = userBean.fetch({

    success: _.bind(function(data) {
    //console.log("success");

    //get user's branch
    if (userBean.get("branch_c"))
    {
    //console.log("Get user branch");
    branch_user = (userBean.get("branch_c"));
    //console.log(branch_user);
    this.model.set('branch_c', branch_user);
    }


    },this),

    });


    },

    })

    Hope this help someone!!

    Sergio N.

Reply
  • Hi Stephan,

    You can extend the create.js, create a function that triggers every time there is a change on the view. Through the js code you can pull the value of the related record. Something like this:

    ({
    extendsFrom: 'CreateView',

    initialize: function(options) {
    this._super("initialize", [options]);
    this._populateFields();
    this.model.on('change:assigned_user_id', this._populateFields,this);
    },

    _populateFields: function() {

    var self = this;

    var userBean = app.data.createBean('Users', {id:self.model.get("assigned_user_id")});
    var branch_user;

    var request = userBean.fetch({

    success: _.bind(function(data) {
    //console.log("success");

    //get user's branch
    if (userBean.get("branch_c"))
    {
    //console.log("Get user branch");
    branch_user = (userBean.get("branch_c"));
    //console.log(branch_user);
    this.model.set('branch_c', branch_user);
    }


    },this),

    });


    },

    })

    Hope this help someone!!

    Sergio N.

Children
No Data