Mobile query result in business rule

 Hello Team.

 

There is any way to get the value of the record in the store.loadPage?

I can access to the record parameter inside of the callback.

Terrasoft.sdk.Model.addBusinessRule("ExpensesDetail", {
	name: "GetRoleFromtheUser",
	ruleType: Terrasoft.RuleTypes.Custom,
	triggeredByColumns: ["Subcategory"],
	events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
	executeFn: function(record, rule, column, customData, callbackConfig) {
 
 
		var myrecord = record;
 		var passedTheTestAndIsValid = true;
 
		var currentUser =Terrasoft.CurrentUserInfo.userId;
		var store = Ext.create('Terrasoft.store.BaseStore', {
			model: 'SMVwUserRoles'
		});
		var queryConfig = Ext.create('Terrasoft.QueryConfig', {
			columns: ['SMId', 'SMUserName', 'SMRoleName'],
			modelName: 'SMVwUserRoles'
		});
		store.loadPage(1, {
			queryConfig: queryConfig,
 
			filters: Ext.create('Terrasoft.Filter', {
				property: 'SMId',
				value: currentUser
			}),
			callback: function(records, operation, success) {
				var loadedRecord = records[0];
				if (loadedRecord) {
					var contact = loadedRecord.get('SMRoleName');                                                                                                    
					if (contact) {                                                                                                                   
						console.log(contact);
					}
					}
				},
					scope: this
			});
 
	},
	position: 3
});

 

Like 0

Like

2 comments
Best reply

Hello Federico,

 

You have the myrecord variable and it's accessible inside the loadPage method:

So you can access the record parameters if needed there.

 

Best regards,

Oscar

Hello Federico,

 

You have the myrecord variable and it's accessible inside the loadPage method:

So you can access the record parameters if needed there.

 

Best regards,

Oscar

Oscar Dylan,

 Thanks Oscar, I my case sending the scope: this was not working but changing the scope works.

Show all comments