refresh record in mobile app

Hi Team. I have a code to save a change in the record. The change is impact in the database but the lookup is stay in until the next sincronization. There is a way to refresh or push the sync for that particular record in the mobile app?

onClickMeButtonClick: function() {
		var record = this.getRecord();
		var recordId = record.getId();
		if (record.data.AgilizExpenseStatus.data.Id != "0bbc321a-77cd-4d20-a929-b5bbb34c74bc") {
 
			Terrasoft.ServiceHelper.issueRequest({
				serviceName: "SMExpensesManagmentValidator",
				methodName: "AttachmentsValidation",
				data: {
					Id: recordId
				},
				success: function(response) {
					if (response.AttachmentsValidationResult == "") {
						record.set("AgilizExpenseStatus", "0bbc321a-77cd-4d20-a929-b5bbb34c74bc", true);
 
						record.save({ 
							queryConfig: Ext.create('Terrasoft.QueryConfig', { 
								modelName: record.self.modelName,
								columns: ['AgilizExpenseStatus']
							}),
							success: function() {
 
//here I need to refesh the record.
								Terrasoft.MessageBox.showMessage(LocalizableStrings.SummitForApproval); 
 
							},
							failure: function(exception) { 
								Terrasoft.MessageBox.showException(exception); 
							}
						}, this);
					} else {						
 
					}
				},
				failure: function(response) {
					Terrasoft.MessageBox.showMessage("Error in webservice");
				},
				scope: this
			});
		} 
	}

 

 

Like 0

Like

5 comments
Best reply

Federico Buffa ?,

 

Ok, got it. You need to somehow call the refreshDirtyData method inside your method. As stated in the base page controller module:

/**
	 * Refreshes obsolete data on page.
	 * @internal
	 * @virtual
	 * @param {Object} operationConfig Configuration of operation.
	 */
	refreshDirtyData: function(operationConfig) {
		if (operationConfig) {
			this.refreshDirtyDataByOperationConfig(operationConfig);
		} else {
			this.loadData();
		}
	},

An example of a call of this method can be found in the FieldMobileVisitActions module (FieldMobile package):

onCheckInOutSucceeded: function(isCheckIn) {
        var record = this.getActivityRecord();
        var statusId = isCheckIn
            ? Terrasoft.Configuration.ActivityStatus.InProgress
            : Terrasoft.Configuration.ActivityStatus.Finished;
        record.set("Status", ActivityStatus.Store.getById(statusId));
        var queryConfig = Ext.create("Terrasoft.QueryConfig", {
            columns: ["Status"],
            modelName: record.self.modelName
        });
        record.save({
            isCancelable: false,
            queryConfig: queryConfig,
            success: function() {
                this.complete(function() {
                    var pageController = Terrasoft.PageNavigator.getLastPageController();
                    pageController.refreshDirtyData();
                    Terrasoft.PageNavigator.markPreviousPagesAsDirty();
                    var message = isCheckIn ? Terrasoft.LocalizableStrings.VisitActionDesignerCheckInOk :
                        Terrasoft.LocalizableStrings.VisitActionDesignerCheckOutOk;
                    this.callSuccess(message);
                    Terrasoft.Mask.hide();
                });
            },
            failure: function(exception) {
                this.callFailure(exception);
                Terrasoft.Mask.hide();
            }
        }, this);
    },

Hi Federico,

 

It can be the result of the missing lookup object in the SysLookupsImportConfig array of the mobile application manifest. You need to check if the object of your lookup is present there.

Hi Oscar, the lookup is there and is working with the manual selection just when I set the id in the button is showing like that's like if the sync is missing or something is not refresh.

Federico Buffa ?,

 

Ok, got it. You need to somehow call the refreshDirtyData method inside your method. As stated in the base page controller module:

/**
	 * Refreshes obsolete data on page.
	 * @internal
	 * @virtual
	 * @param {Object} operationConfig Configuration of operation.
	 */
	refreshDirtyData: function(operationConfig) {
		if (operationConfig) {
			this.refreshDirtyDataByOperationConfig(operationConfig);
		} else {
			this.loadData();
		}
	},

An example of a call of this method can be found in the FieldMobileVisitActions module (FieldMobile package):

onCheckInOutSucceeded: function(isCheckIn) {
        var record = this.getActivityRecord();
        var statusId = isCheckIn
            ? Terrasoft.Configuration.ActivityStatus.InProgress
            : Terrasoft.Configuration.ActivityStatus.Finished;
        record.set("Status", ActivityStatus.Store.getById(statusId));
        var queryConfig = Ext.create("Terrasoft.QueryConfig", {
            columns: ["Status"],
            modelName: record.self.modelName
        });
        record.save({
            isCancelable: false,
            queryConfig: queryConfig,
            success: function() {
                this.complete(function() {
                    var pageController = Terrasoft.PageNavigator.getLastPageController();
                    pageController.refreshDirtyData();
                    Terrasoft.PageNavigator.markPreviousPagesAsDirty();
                    var message = isCheckIn ? Terrasoft.LocalizableStrings.VisitActionDesignerCheckInOk :
                        Terrasoft.LocalizableStrings.VisitActionDesignerCheckOutOk;
                    this.callSuccess(message);
                    Terrasoft.Mask.hide();
                });
            },
            failure: function(exception) {
                this.callFailure(exception);
                Terrasoft.Mask.hide();
            }
        }, this);
    },

Thanks Oscar. works!

Oleg Drobina,

Will this also refresh embedded details associated with the record?

Show all comments