How do I get url via javascript ?

Hi,

I try to get by this code but Sugar throw error "cannot render view please contact technical support".

How to disable sub panel row actions conditionally based on parent model?   I copy from this issue.

Code which I comment makes this error.

in /custom/clients/base/fields/phone/phone.js

({
user_id: "NOTINIT",
plugins:['EllipsisInline'],
direction:'ltr',
initialize:function(options){
        var serverInfo=app.metadata.getServerInfo();
        //this.parentModule=this.context.parent.get('model').module;
        //this.parentCollection = this.context.parent.get('collection');
        //this.parentModel=this.context.parent.get('model');
        this.user_id = app.user.id;
        this.skypeEnabled=serverInfo.system_skypeout_on?true:false;
        this._super('initialize',[options]);
},
...
})

Sugar 7.6 Ent

Thanks,

M

Parents
  • Hi Autchara,

    You can reach current fragmentation with;

    app.router.getFragment(); // "Accounts/646408f2-7b20-24d7-3e77-571a2e5ecd0d" 
    

    Using fragmentation you can build your url.

    About render error, you are trying to access not defined properties.

    It would resolve that render error by changing the code like;

    if( this.context && this.context.parent ){
        this.parentModule = this.context.parent.get('model').module;  
        this.parentCollection = this.context.parent.get('collection');  
        this.parentModel = this.context.parent.get('model');
    }
    

    But I doubt that this is a correct approach to get them. If you were trying to build fragmentation by getting Module name and record id then recommend to use `getFragment()`.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • ({  
    user_id: "NOTINIT",
    plugins:['EllipsisInline'],
    direction:'ltr',
    initialize:function(options){
            var serverInfo=app.metadata.getServerInfo();
            this.user_id = app.user.id;
            this.getURL = app.router.getFragment();
            this.skypeEnabled=serverInfo.system_skypeout_on?true:false;
            this._super('initialize',[options]);
    },  
    ...  
    }) 
    

    After I put code above instead but still error.

    Could you please help me to check my code are correct or not.

  • Hi Autchara,

    I provide my examples for always for latest version(7.7). You are receiving error message because getFragment method is not exist in 7.6.

    But you can still get the fragment through Backbone. So please change your code like this;

    this.getURL = Backbone.history.fragment;
    

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • Thank you million time Its work perfect with below code in 7.6

    this.getURL = Backbone.history.fragment;  
    

    Can I use this function in 7.7 or not if I upgrade 7.6 to 7.7 ?

Reply Children