Why do model attributes at panel setup function contain an incomplete list of fields?
We need to reload the page in browser to get the full model
We need to reload the page in browser to get the full model
{"id":"62e77dc43f2b02ff9","name":"CRM PropGen TEST 02","amount":629.5,"stage":"Document approval","createdAt":"2022-08-01 07:16:20 ","number":"PN200029","amountCurrency":"EUR","accountId":"62abac439221a00c9","accountName":"cfw","createdById":"62aac759ee724b23b","assignedUserId":"62aac759ee724b23b", "assignedUserName":"PM Tester"}
define('custom:views/opportunity/panels/custom-links-panel', ['views/record/panels/side'], function (Dep) {
return Dep.extend({
templateContent: '<div> \
<a href="http://localhost/add.php?idOpportunity={{ this.model.id }}&idUser={{ viewObject.userId }}&token={{ viewObject.token }}" target="_blank">Create
or edit...</a><br/>\
<br/>\
<a href="{{ viewObject.aLink }}">Create new project...</a>\
</div>\
',
setup: function () {
Dep.prototype.setup.call(this);
this.wait(
this.model.fetch()
);
this.addName = '';
this.addName += this.model.attributes.a ? '&addname[]=A' : '';
this.addName += this.model.attributes.fs ? '&addname[]=FS' : '';
this.addName += this.model.attributes.ps ? '&addname[]=PS' : '';
this.addName += this.model.attributes.po ? '&addname[]=PO' : '';
this.addName += this.model.attributes.so ? '&addname[]=SO' : '';
this.addName += this.model.attributes.c ? '&addname[]=C' : '';
this.addName += this.model.attributes.otherCheckbox ? 'Other' : '';
var user = this.getUser();
this.userId = user.id;
this.userName = user.attributes.userName;
this.token = user.attributes.pgToken;
console.log(this.model);
console.log(user);
console.log(JSON.stringify(this.model.attributes)) ;
this.aLink = 'http://localhost2/api/createproject?'
+'anketkapid=' + (this.model.attributes.projectNumber == undefined ? '': this.model.attributes.projectNumber)
+'&managerId=' + user.attributes.userName
+'&name=' + this.model.attributes.name
+'&oppId=' + this.model.id
+'&company=' + this.model.attributes.accountShortName
+'&ir_plan=' + this.model.attributes.irPlan
+'&loi_plan=' + this.model.attributes.loiPlan
+'&totalcompletes=' + this.model.attributes.nPlan
+'&sfuniquepn=' + this.model.attributes.number
+ this.addName + '&key=' + this.token
+'&sftarget_a__c=' + encodeURI(this.model.attributes.targetAudience);
},
});
});
Comment