Add City field in Activities/Visit

Hello,

We would like to add the City of an Account in the Visit Scheduler container. How can that be achieved ?

Thank you

Sasori

Like 0

Like

8 comments

Hello team,

Any update on this ?

Sasori Oshigaki,

Hello,

This title is composed in the schema ActivitySectionGridRowViewModel and its method getScheduleItemTitle and if you want to change the title, you need to modify this method. Keep in mind that you cannot simply override schema ActivitySectionGridRowViewModel, you need to write a new nodule with a code similar to ActivitySectionGridRowViewModel with the exception of the needed method and connect your new schema to the base schemas similar to an old ActivitySectionGridRowViewModel

Hi Creatio,

I have managed to retreive the City Valye.

My last hurdle is how to set the retrieved city string value to a global attribute inside the ESQ, because as you know ESQ is aysnc.

 

This is the Global attribute:

attributes: {
		"CityNameEsq": {
		dataValueType: this.Terrasoft.DataValueType.TEXT,
		type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
		}	
	},

This is the method:

getScheduleItemTitle: function() {
		    this.callParent(arguments);
			var title = this.get("Title");
			var account = this.get("Account");
			var accountGuid = this.get("Account").value;
 
				var recordId = this.get("Account").value;
					var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
						rootSchemaName: "Account"
					});
					esq.addColumn("City.Name", "CityName");
					esq.getEntity(recordId, function(result) {
						if (!result.success) {
							// For example, error processing/logging.
							this.showInformationDialog("Data query error");
							return;
						}
						this.set("CityNameEsq", result.entity.get("CityName"));

Sasori Oshigaki,



Here is a sample to get the result of an asynchronous function using Terrasoft.chain

getMyEntity: function(callback) {
    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
        rootSchemaName: schemaName
    });
    ...
    esq.getEntity(recordId, function(response) {
        ...
        if (callback) {
            callback.call(this);
        }
    }, this)
},
globalMethod: function() {
    Terrasoft.chain(
        function(next) {
            this.getMyEntity(function() {
                next();
            });
        },
        function() {
            this.doAfterGettingEntity();
        },
        this
    );
}

Also, please check this article's getentity method to synchronous!



 

 

BR,

Bhoobalan Palanivelu.

Bhoobalan Palanivelu,

Thank you very much Bhoobalan. As always you help is much appreciated.

I am still not getting the wanted result.

Here is the entire module code

define("SasActivitySectionGridRowViewModel", ["ActivitySectionGridRowViewModel","ActivitySectionGridRowViewModelResources"
	],
		function() {
 
	/**
	 * @class Terrasoft.configuration.ActivitySectionGridRowViewModel
	 */
	Ext.define("Terrasoft.configuration.SasActivitySectionGridRowViewModel", {
		alternateClassName: "Terrasoft.SasActivitySectionGridRowViewModel",
        override: "Terrasoft.ActivitySectionGridRowViewModel",
	    attributes: {
					"CityNameEsq": {
						dataValueType: this.Terrasoft.DataValueType.TEXT,
						type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
					}
 
				},
		/**
		 * ########## ######## ######### ######## # ##########.
		 * @return {String} ######## ######### ######## # ##########.
		 */	
		getScheduleItemTitle: function() {
			Terrasoft.chain(
			function(next) {
				this.GetCityName(function() {
					next();
				});
			},
				function() {
				this.getTitleInfo();
			},
			this
		);
		},
 
		GetCityName: function(callback)
		{
			debugger;
			var recordId = this.get("Account").value;
			var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
				rootSchemaName: "Account"
			});
			esq.addColumn("City.Name", "CityName");
			esq.getEntity(recordId, function(response) {
				if (!result.success) {
					this.showInformationDialog("Data query error");
					return;
				}
				this.set("CityNameEsq", result.entity.get("CityName"));
			}, this);
		},
 
		getTitleInfo: function()
		{
			var title = this.get("Title");
			var account = this.get("Account");
			var accountDisplayValue = (account) ? account.displayValue + ": " : "";
			return Ext.String.format("{0}{1}", accountDisplayValue, title,this.get("CityNameEsq"));
		}
 
	});
 
	return Terrasoft.SasActivitySectionGridRowViewModel;
});

What am in doing wrong here. Because i get

Sasori Oshigaki,



Can you please try to add in this method  getScheduleItemTitle: function()

 this.callParent(arguments);

 

Hi Bhoobalan,

Still getting the same result

after applying 

this.callParent(arguments);
	getScheduleItemTitle: function() {
			this.callParent(arguments);
			Terrasoft.chain(
			function(next) {
				this.GetCityName(function() {
					next();
				});
			},
				function() {
				this.getTitleInfo();
			},
			this
		);
 
		},

 

The esq async logic may be pretty complicated. if you have a debug mode enabled, please turn it off, this may fix the issue. If it, not the case, try to change the title in the method getScheduleItemTitle without using ESQ by setting some test value, maybe the problem isn't in the async logic but in the method itself.

Show all comments