Question

Set HTML content into a textarea

Dear,

I m trying to copy an email Model HTML content into a section textarea.

Here's my code:

onUsrModeleIdChange: function() {
 
	var ModeleId = this.get("UsrModeleId").value;
 
	var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
		rootSchemaName: "EmailTemplate"
	});
	esq.addColumn("Body");
 
	esq.filters.add("IdFilter", esq.createColumnFilterWithParameter(
		Terrasoft.ComparisonType.EQUAL, "Id", ModeleId));
 
	esq.getEntity(ModeleId, function(result) {
 
		var BodyContent=result.entity.get("Body");
 
		this.set("Corps", BodyContent);
	});
},

I get the BodyContent variable, but the this.set comes out in error:

I don't understand why the this.set does not works.

Is it because the field is an textArea ?

Thank you !

Nicolas

 

Like 0

Like

3 comments
Best reply

As an FYI, you can retain the scope by passing this as the final parameter to the ESQ getEntity. 

esq.getEntity(ModeleId, function(result) {
    var BodyContent=result.entity.get("Body");
    this.set("Corps", BodyContent);
}, this); // note 'this' passed as final parameter

This is also the case with getEntityCollection:

esq.getEntityCollection(function(result) {
    // scope retains 'this' context
}, this);

Ryan

context error...

i used: var scope = this; to reach the object

onUsrModeleIdChange: function() {
	var scope = this;
 
	var ModeleId = this.get("UsrModeleId").value;
 
	var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
		rootSchemaName: "EmailTemplate"
	});
	esq.addColumn("Body");
 
	esq.filters.add("IdFilter", esq.createColumnFilterWithParameter(
		Terrasoft.ComparisonType.EQUAL, "Id", ModeleId));
 
	esq.getEntity(ModeleId, function(result) {
 
		var BodyContent=result.entity.get("Body");
 
		scope.set("Corps", BodyContent);
		scope.save();
	});
},

 

As an FYI, you can retain the scope by passing this as the final parameter to the ESQ getEntity. 

esq.getEntity(ModeleId, function(result) {
    var BodyContent=result.entity.get("Body");
    this.set("Corps", BodyContent);
}, this); // note 'this' passed as final parameter

This is also the case with getEntityCollection:

esq.getEntityCollection(function(result) {
    // scope retains 'this' context
}, this);

Ryan

Ryan Farley,

Hello Ryan and thank you for the reply !

Do you know how i can retrieve the message template Body in french ?

Ryan Farley writes:
var BodyContent=result.entity.get("Body"); //in french ?

Show all comments