AnsweredAssumed Answered

Prepopulate Email not working

Question asked by Francesca Shiekh on Jan 15, 2015
Latest reply on Jan 20, 2015 by Francesca Shiekh
I have a custom rowaction on Emails subpanel on cases.



         

mysugar/custom/modules/Emails/clients/base/views/subpanel-for-cases-archived_emails/subpanel-for-cases-archived_emails.php

  'rowactions' => array (
    'actions' => array (
      array(
        'type' => 'rowaction',
        'css_class' => 'btn',
        'event' => 'list:customemailreply:fire',
        'tooltip' => 'Reply to email',
        'icon' => 'icon-reply',
        'acl_action' => 'create',
     ),
   ),
 ),
                                     

The idea is to click the reply button for the particular email and get an Email Compose drawer with some information pre-populated (effectively as you would expect from an email reply button)
The problem is the drawer opens but I can't get the prepopulate to work.

               
({
  extendsFrom:'SubpanelListView',
  initialize: function(options){
    console.log('custom/modules/Emails/clients/base/views/subpanel-list/subpanel-list.js');
    this._super('initialize', [options]);
    this.context.on('list:customemailreply:fire',this.customReplyClicked, this);
  }, 
  customReplyClicked: function(){
    var replyToEmailBean = app.data.createBean('Emails', {id: this.model.id});
        request = replyToEmailBean.fetch();
    request.xhr.done(function(){
      var desc = replyToEmailBean.get('description') ||'',
          desc_html = replyToEmailBean.get('description_html') ||'',
          options = ({
            parent_id:replyToEmailBean.get('parent_id'),
            parent_name:replyToEmailBean.get('parent_name'),
            parent_type:replyToEmailBean.get('parent_type'),
            name:replyToEmailBean.get('name'),
            description:replyToEmailBean.get('description'),
            description_html:replyToEmailBean.get('description_html'),
            to_addresses:replyToEmailBean.get('reply_to_addr'),
            from_address:replyToEmailBean.get('to_addrs_names')
      });
      app.drawer.open({
         layout:'compose',
         context:{
           create: true,
           prepopulate: options,
           module:'Emails',
         }
      });
   });
  }
});
                                                                 


I'm a bit confused by the prepopulate function in

modules/Emails/clients/base/views/compose/compose.js

I have verified that it is running but when I console log the values object it looks fine but then it gets flipped in the _.each statement.

Making the definition value:fieldName just doesn't look right (and still doesn't work...)

    prepopulate: function (values) {
        var self = this;
        _.defer(function () {
            _.each(values, function (value, fieldName) {
                switch (fieldName) {
                    case 'related':
                        self._populateForModules(value);
                        self.populateRelated(value);
                        break;
                    default:
                        self.model.set(fieldName, value);
                }
            });
        });
    },
                                           

Am I misunderstanding the purpose of the prepopulate in the context?

thanks,
FrancescaS

Outcomes