
When having a detail with only one lookup, using a whole new edit page for it isn’t really needed, a lookup pop up is all you’d need. The academy has already gone over this but I thought I would just simplify the article. For my example I will create a case subscription detail where you can select contacts in a pop up lookup. Whens it’s all done it will look like this.
First step is making a detail the normally way you would, create the object and use the detail wizard.
All the code from this article will go in the detail schema and not the page. The detail wizard usually names this something like “UsrSchema37442371Detail”.
Open up your detail schema and there isn’t a lot in there it will look like this.
define("UsrSchema37442371Detail", ["LookupMultiAddMixin"], function() { return { entitySchemaName: "UsrCaseSubscription", details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/, diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/, methods: {} }; });
We’ll paste in the code to make it look something like this.
define("UsrSchema37442371Detail", ["LookupMultiAddMixin"], function() { return { entitySchemaName: "UsrCaseSubscription", details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/, diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/, mixins: { LookupMultiAddMixin: "Terrasoft.LookupMultiAddMixin" }, methods: { init: function() { this.callParent(arguments); this.mixins.LookupMultiAddMixin.init.call(this); }, getAddRecordButtonVisible: function() { return this.getToolsVisible(); }, onCardSaved: function() { this.openLookupWithMultiSelect(); }, addRecord: function() { this.openLookupWithMultiSelect(true); }, getMultiSelectLookupConfig: function() { return { rootEntitySchemaName: "Case", rootColumnName: "UsrCase", relatedEntitySchemaName: "Contact", relatedColumnName: "UsrContact" }; } } }; });
Here’s what I added to the original detail schema. You’ll paste in the code exactly how it is (this is the same code from the academy article with comments cleaned out) – no need to make any changes to the code.
- The “LookupMultiAddMixin” string in the top, between the square brackets
- The mixins section
- The methods section
Be sure to replace an existing section so you don’t end up with duplicates. Also, be sure you don’t replace the line for entitySchemaName and also the first string in the file after “define” (the name of the detail schema).
This last part is important. At the end of that code, you need to change 4 things:
- rootEntitySchemaName – This is the parent object type. Whatever is the parent object of your detail needs to go here. This is usually the object of the page your detail is on, so if it’s on the Case page, this would be “Case”
- rootColumnName – The column on the detail object that relates to the parent object goes here.
- relatedEntitySchemaName – Whatever you are trying to lookup goes here.
- relatedColumnName – The column on the detail to put the lookup results in goes in here.
If you test this and the lookup is empty it’s probably because these last parts are filled in wrong.
Hey Tate,
Can you please tell what is the type of relatedColumnName column present in Detail ?
Hi Ramnath,
The relatedColumnName value is the name of the column on the detail object where the result of the lookup is stored. Basically, whatever it is you’re looking up to add to the detail will get set in this column. For example, if I added a detail called “Account products” where products could be added to an account. We’ll assume my object is named “UsrAccountProduct” and it has these columns UsrAccount (an account lookup, which relates it to the parent account) and UsrProduct (a product lookup). This detail is on the Account page and when the + button is clicked we want to lookup products to add to this detail. In that scenario, we’d set that up with the following:
rootEntitySchemaName: Account
rootColumnName: UsrAccount
relatedEntitySchemaName: Product
relatedColumnName: UsrProduct
Hope this helps,
Ryan
Thanks Ryan
Now I understood it fully and I can add this feature to my solution.