Issue while using Bean CreateRecord - Transaction Log

A custom functionality has been developed on SugarCRM Mobile App, using the SugarCRM Mobile SDK. The functionality that is required to achieved is to capture the user's current geolocation and send to SugarCRM , in a one minute interval. This has been achieved through a custom module creation.

The customer module contains the geolocation details such as longitude and latitude.

When the user is connected to a internet(wifi connection /mobile data connection) and is online via the SugarCRM App, this custom module functionality that was coded for works fine, however when the user is offline, SugarCRM should be able to store all such geolocation details captured in the transaction log. Subsequently when the user gets to online mode, the mobile app is expected to send this information into SugarCRM.

Additional Information : As there are two ways in which a record can get created within the SugarCRM (Mobile App and User Interaction)

1: A Record gets created through built in API, this is working as expected.
2: Creating a Bean of the specific Module, this is not working as expected and is generating an error "Resource Not Found", since there is no transaction log that gets created as a result of Bean CreateRecord function call.

import customization from '%app.core%/customization';
import NomadView from '%app.views%/nomad-view';
import device from '%app.core%/device';
import dialog from '%app.core%/dialog';

var dialogTest;

const CustomDialog = customization.extend(NomadView, {
    template: 'custom-dialog',
	_bodyScroll: true,
	events() {
        return {
            'click button#btn_showDialog':this.showDialog,
            'click button#btn_closeDialog':this.closeDialog, 
            'click button#btn_createBean':this.createBeanCustom, 
        };
    },
	
    headerConfig: {
        title:'Custom Dialog',
        buttons: {
            mainMenu: true,
        },
    },

    initialize(options) {
        this._super(options);			
    },
	
	showDialog() {
		dialogTest.showModal();
	},
	
	closeDialog() {
		dialogTest.close();
	},
	
	createBeanCustom(){
		var bean = app.data.createBean('Notes', {id: generateUUID(), name:'Custom Mobile Note'});	
		bean.save(null, {
			fields: Object.keys(bean.attributes),
			hasCustomSuccessAlert: true,
			success: model => {
				
			},
			error: () => {
				
			},
		});
	},
		
	onAfterRender() {		
		dialogTest = document.getElementById("myDialog");
	}
});

function generateUUID() { // Public Domain/MIT
    var d = new Date().getTime();//Timestamp
    var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random() * 16;//random number between 0 and 16
        if(d > 0){//Use timestamp until depleted
            r = (d + r)%16 | 0;
            d = Math.floor(d/16);
        } else {//Use microseconds since page-load if supported
            r = (d2 + r)%16 | 0;
            d2 = Math.floor(d2/16);
        }
        return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
    });
}

customization.registerRoutes([
    {
        name: 'custom-dialog',
        steps: 'custom-dialog',
        handler() {
            app.controller.loadScreen(CustomDialog);
        },
    },
]);


//Adding menu to the main menu
customization.registerMainMenuItem({
    label: 'Custom Dialog',    
    route: 'custom-dialog',
    rank: 3, 
});

module.export = CustomDialog;

Parents Reply Children
No Data