Sugar 7 - CreateView not working

Hello.

I'm using Sugar Enterprise 7.5 for production system, and 7.7 for test system.

I need to change a datetime module field value in the page as soon as the page is loaded. It's for a custom module.

The first solution was to use "calculated fields", but there is a bug in the production system where the calculated field option is not working (in the test system it works).

I already contacted the Sugar Enterprise Case Portal support, but for now there is no definitive solution, so I need some client-side workaround for this...

Only for information, this is the case I opened:

https://web.sugarcrm.com/support/cases/ed616e88-3c09-b55e-0f3d-5762edd4f032

The worse, I've tried several tutorials about customizing the module form in CreateView, but none of them worked.

It isn't even printing something on the browser console. I've already succeed on printing on console with a RecordView code (for form validation).

For now, I only need the CreateView validation working, I will do the remaining field logic later.

There is the code, in the create-actions.js file (not working):

({  
    extendsFrom: 'CreateView',  
    initialize: function(options) {                       
        this._super('initialize', [options]);                                    
        this.on('render', this.testFunc, this);  
    },  
    testFunc: function() {    
        console.log("Test");  
        _.each(this.fields, function(field) {  
            if (_.isEqual(field.def.name, 'data_init')) {  
                console.log("entered");   
            }  
        }, this); 
    },  
})  

Any help would be appreciated.

Thanks!

Parents
  • Hello Ramon,

    Hope you are doing good.

    Bind your function on render event.

    ({    
        extendsFrom: 'CreateView',    
        initialize: function(options) {                         
            this._super('initialize', [options]);                                      
            this.on('render', _.bind(this.testFunc, this));
        },    
        testFunc: function() {      
            console.log("Test");    
            _.each(this.fields, function(field) {    
                if (_.isEqual(field.def.name, 'data_init')) {    
                    console.log("entered");     
                }    
            }, this);   
        },    
    })
    

    This is working fine for me in ENT 7.7

    Hope it will help you.

    Let me know for more help.

    -BPATEL

  • Hello Bhavesh,

    Thanks for the help, but it didn't worked (like most things I'm trying to do in Sugar Enterprise recently, especially with javascript / backbone.js).

    Nothing happens when going to the create page.

    The only thing that happened was the Edit Button that disappeared when accessing the record.

    It's frustrating that in Sugar Enterprise, a simple page validation that I would do in a few minutes with jQuery, is taking me several days to not even getting something to work...

    CreateView validations doesn't work, record views saving before custom client validation, calculated fields not working (when it should), repair option not repairing anything, and a bunch of other problems that are plaguing my business as a programmer, making me feel incompetent...

    I will be uploading here a zip package with all the file structure, if you want to check it, please. (RegistroLigacoesApi.zip)

    This is a print screen showing where I want to change the value, and below, the console not showing anything...

    createview_fill_field.png

    Maybe I'm still making something wrong...

    If someone can help me, I will be grateful.

    Thanks.

  • Hello,

    Your code works just fine for me. Couple of checks. Clear everything from cache module + Clear the browser cache. Excuse me if you have done this already, but worth giving a try!

  • Hello.

    Can you show a print screen of this working, please?

    I've already cleaned browser cache, and all the cache I could clear in the system, as it is a OnDemand instance.

    Thanks.

  • Hi Ramon,

    Do you use Google Chrome as a Browser?

    Then you can do this. Open your Developer Tools then hold your mouse on refresh button. You will get three options. Choose Empty Cache and Hard Reload.

    This will clear browser cache and then reload every single request without using Cache.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

Reply Children