Attach Button get Related records by filtering

Posted by IramK on 18-Feb-2015 05:46


I have three objects (Account, Apps, Opps) with the following relationships:

1) Account - Apps (1:M)

2) Account - Opps (1:M) 

3) Apps - Opps (M:M)

When I create an Opps record I have to specify an Account (required).On the view page of the Opps record, I have the option of attaching a Apps record to it. I would like to filter this Apps record attach option to show only the records that are linked to that Account.

So basically:

Attach Apps: Apps attached to the Account that for that Opps record.

How can I achieve this? By default the Attach Apps button shows all the available Apps. Is there a way I could filter it to show only the Apps related to that Account for that Opps record?

All Replies

Posted by Godfrey Sorita on 18-Feb-2015 09:21

Hi Iram,

The dialog page that is displayed after clicking the "Attach" button is actually a Selector page. This will allow you to filter the records by configuring the page:
1. Set a default view filter.
2. Disable the "Set View Selector".

Unfortunately this option cannot be used in your scenario because the filter value is dynamic. The rbf_setLookupFilter function is used for dynamic filttering but it can only be used on lookup fields in selector mode. If possible, you can use the lookup fields instead of using the "attach" button. Otherwise, you can file an enhancement request from the ideas section (


Posted by IramK on 18-Feb-2015 11:51

When we perform a selection on a related record on the attach selector page, what happens when a selection is made i.e. what non-documented function is called on that selection that closes the modal pop-up and attaches the record to the record in scope? I can see a rbf_attachRelated(...) is called but I don't understand its parameters and what I could do to get this functionality working.

Posted by Godfrey Sorita on 18-Feb-2015 12:53

There are several undocumented functions that are fired when selecting a record from the attach selector page. Below are the sequential calls done on the page:
1. selectObj(objId, objName)
2. createNNNNN(objId2)
3. rbf_doRelCreate(listForm,objId,actValue)

Just a friendly reminder, undocumented functions may change from time to time during upgrades. And even if you can successfully call these functions, the issue on dynamically filtering records still exists.

The best workaround I can think of is to use workflow. On the workflow page, you'll need a lookup field and a script component. The script component will hide the lookup field and generate the rows and columns of Apps. When a record is selected, you'll need to create a function to set the value of the hidden lookup field so the selection will be saved.

This will still require a lot of other handling, of course.

Posted by IramK on 23-Feb-2015 05:40

Hello [mention:9c7be15f444c42e4809af5b84a23adff:e9ed411860ed4f2ba0265705b8793d05] ,

Could you suggest me as to how I can use the workflow option in detail please? I'm not using workflows as a part of my object attribute currently.

Also as an idea, can I create a new View dynamically that would do the filtering based on the current related record?

Posted by Godfrey Sorita on 24-Feb-2015 10:30

Here's a more detailed explanation on the workaround:

1. Enable "Workflow" attribute on your object.

2. Create a new workflow action with the following configuration:

> Type: Status Change
> Use Web Page: Status Change
> Enable "Group Action"

3. Edit the default "Created" workflow status and allow the newly created workflow action to be used for records with this status.

4. Edit the "Status Change" page.

5. Create a new section and drag the Application lookup field inside.

6. Create a new section and drag a Script Component inside.

7. On the script component, create a code that will hide the lookup field and generate the rows and columns of Apps.


  #rbi_L_R27938, #rbi_F_R27938 { display: none; }

$(function() {
  rbf_selectQuery("SELECT id, name FROM org WHERE R17032 = {!R27938}", 1000, function(data){ 
    for (x=0; x<data.length; x++) {
      $("#container").append('<div id="item"><a onClick="setLookup(' +data[x][0]+ ')">' +data[x][1]+ '</a></div>');

function setLookup(recordId){
  rbf_setFieldValue("R27938", recordId);

<div id="container">

Important: Please update the tokens and integration names of fields on this code.

You should be able to test it be changing a record's status to "Created".

Posted by Manooj Murali on 27-Feb-2015 06:10

This could be something that has already been discussed, but would like to put out my thoughts anyway.

We have a feature in rollbase Main-Link lookup which can help achieve this behavior but we can make it work only by using the selector (i.e. new/edit of Opps). All you need to do is

1. Edit the 'Apps' lookup field in 'Opps' object definition.

2. Select Main-Lookup as 'Opp-Account'.

3. Select Link-Lookup as 'App-Account'.

Now, whenever a new Opps is created/edited, the Apps selector will only show entries that are related to the Account selected for that record.

Now, coming to the 'Attach' functionality available on the 'Opps' view page, yes it is a view but this view can be customized with filters to display the choices you need. I haven't worked out a solution with this approach yet, but seems possible. I will get back on this space if I can work something out.



Posted by IramK on 27-Feb-2015 06:12

Yes thanks for that [mention:1b78ce1c2c2a4204bd296c4a20853160:e9ed411860ed4f2ba0265705b8793d05] . I have already got that working using the Main-Lookup and Link-Lookup for the selector field but am just interested in the attach for now. I have a suggestion:

Can we not use the same pop-up window that gets the filtered result back when we click on the search button on the selector - onto the Attach button click? I know it doesn't work in the same way which is why I asked what sort of undocumented functions I could use to do this. I have tried changing the attach button onclick functionality to do the same that the selector search button does, but selecting an item does not attach a record. Possibly that could be a solution?

Looking forward to your reply.


Posted by ByronB on 16-Mar-2015 06:18

I am also struggling with this, I am needing to filter my attach selector list by the parent object. Any further suggestions regarding how best to achieve this functionality?

Posted by IramK on 26-Jun-2015 10:18
This thread is closed