First off, let me say I know I ask a lot of questions here and never seem to contribute, but I promise that's gonna change. I've been on a massive project for the last 6 months and I have learned a metric ton of tips and tricks that I plan on documenting for everybody. I have a whole bunch of sketches in a file I've titled "howthe<censored>didIdothat.txt" that I need to clean up. But the posts are coming.
Now then, on to my question:
I've got a custom view/layout that is loading and leveraging records from 6 or 8 different modules in SugarCRM. The layout/view/module itself doesn't contain anything. It's basically a carrier for the view which builds itself around the data from these various modules, depending on the situation. For simplicity sake, lets say it only leverages data from 3, Contacts, Accounts and CustomModule.
When I use the QuickCreate (+ in upper right) to say log a call, or an email, depending on a number of factors in the current situation, I may want to log that call or email against the Contact record, or the Account Record, or the CustomModule record.
Based on a *lot* of trial and error, I put some logic in to make some changes to the passed object if the drawer was being opened as a result of an action from my layout (therefore not impeding anything if the QC functions were used elsewhere.)
Ultimately, the changes I made were as follows (summarized, as they're a bit different depending on the module/record I wanted to pre-relate):
this.options.context.attributes.module = "CustomModule";
this.options.context.attributes.modelId = customModuleID;
this.options.context.attributes.model.id = customModuleID;
this.options.context.attributes.model.isNotEmpty = true;
this.options.context.attributes.model.dataFetched = true;
this.options.context.attributes.model.attributes._module = "CustomModule";
this.options.context.attributes.model.attributes.name = customModuleName;
this.options.context.attributes.model.attributes.id = customModuleID;
this.options.context.attributes.viewed = true;
this.options.context.attributes.dataView = 'record';
this.options.context.attributes.action = 'detail';
This works swimmingly. The create drawer for the call opens up and the relationship is pre-defined and relates it to the specified module and record that I provide.
The PROBLEM, is that the ability to change that relationship to one outside CustomModule is now broken.
I can change the Parent Type dropdown to any other module in the system, and the Record chooser defaults to blank, but when I click the "Search for More" option, it always loads a listview of the CustomModule records. Doesn't matter if it's Calls, Quotes, whatever, it always loads CustomModule's listview for the record selector.
This is specifically related to the this.options.context.attributes.module variable, as if I comment that one out of the block, the selectors behave as expected BUT nothing pre-populates any more.
There is a solid chance I have grossly overcomplicated this and I look forward to someone going "NO DUMMY DO THIS <3 lines of code>" and that will be wonderful.
At this point, though. I'll take any guidance I can get!
(look for "How the <censored> did I do that" to be released by O'Reilly Books in 2017*)
* not actually happening in print don't be ridiculous.