How to get Parent ID and context in create.js

Hi all

I'm working on a piece of customisation in the Cases module and need to access Related Parent Fields to set some defaults on the Cases form. Is there any way I can get the Parent ID and its Module name from within the create.js file and its initialise function.

I only want this logic to run when a Case is created via the Accounts module > Cases sub panel and not from the Cases module directly.

Regards

Sone

Parents
  • Hi sonesay inthavong

    When Cases create view is opened from subpanel inside Accounts module, you can get the parent account model inside your create.js for Cases module by using the following code:

    var parent_model = this.context.parent.get('model');

    From this parent model you can get its type and id, or any other fields. e.g:

    parent_model.get('id'); // will return id of the parent Account
    parent_model.get('_module'); // will return module name of the Parent

    When the Cases create view is opened directly from Cases module and not from subpanel, this id and _module attribute on the parent model will be empty. This code is tested on SugarCRM Enterprise, Version 7.10.2.0.

    Hope this helps.

    Kind Regards,
    Rolustech Support
    Email: support@rolustech.com
    Website: www.rolustech.com

Reply
  • Hi sonesay inthavong

    When Cases create view is opened from subpanel inside Accounts module, you can get the parent account model inside your create.js for Cases module by using the following code:

    var parent_model = this.context.parent.get('model');

    From this parent model you can get its type and id, or any other fields. e.g:

    parent_model.get('id'); // will return id of the parent Account
    parent_model.get('_module'); // will return module name of the Parent

    When the Cases create view is opened directly from Cases module and not from subpanel, this id and _module attribute on the parent model will be empty. This code is tested on SugarCRM Enterprise, Version 7.10.2.0.

    Hope this helps.

    Kind Regards,
    Rolustech Support
    Email: support@rolustech.com
    Website: www.rolustech.com

Children
No Data