New UI - Main Lookup/Link Lookup Issue

Posted by Meryk on 17-Dec-2015 11:32

Hello,

I just came across a strange behavior with Link lookup main lookup. So let's say field B is a link lookup on field A in a new page.

I have two functions onChnageofA()  and onChangeofB() that I am calling on change of A and B respectively. those functions are called as events on the field definition.

When I change field A, it looks like onChangeofB() is running as well. Which I don't want obviously.

Can someone please reproduce this and let me know if it is an issue?

Ps : we are on v 4.0.2.

Thanks,

Meryem

All Replies

Posted by Mohammed Siraj on 17-Dec-2015 22:53

Meryem, for any change in value in Main lookup, the Link lookup field is unset. Hence, onchange event is also fired for the Link lookup.

Posted by Meryk on 18-Dec-2015 03:19

Hi Siraj,

Well yes this is why I was thinking.

So how can I achieve what I am trying to do ? I still need the Main Lookup Link Lookup between these two fields A and B. But the values in these two are used separately and independently.

Also, when I run the onchange of A, it is running the onChange of B, but at this point B is still empty so I am getting an error in the selectQuery I have in the function onChange of B.

The only way I can think of, is the remove the rollbase link lookup and filter the field B manually, so that the onChange of B would be called only on Change of B.

Any better suggestions ?

Is that the same behavior in 4.0.4 ?

Thanks

Meryem

Posted by Mohammed Siraj on 18-Dec-2015 03:27

Is that the same behavior in 4.0.4 ?

Yes.

Any better suggestions ?

In the onchange handler for B, you can test if the field is not set or empty & if so, do not proceed any further but instead abort immediately.

Posted by Meryk on 18-Dec-2015 03:49

In the onchange handler for B, you can test if the field is not set or empty & if so, do not proceed any further but instead abort immediately.

Ok this is working fine thanks. But I am still getting the error text message on B when I change only A, as It is a required field & still empty at this point. How can I avoid this as well ?

I am aborting by doing 'return;'.

Thanks Siraj,

Meryem

Posted by Meryk on 18-Dec-2015 03:55

Also on field B I need to show only records that has a code (an integer field in the related object B) different from -1.

I have a view in object B of only those records. But when I select this view for field B in the same New page, it looks like it is ignored as B is already a link lookup on field A.

How can I apply an additional filtering on a link lookup field ? Do I have to do it manually with code?

Thanks

Meryem

Posted by Mohammed Siraj on 18-Dec-2015 04:17

Right, we can apply only filter at a time. Since the field is a link lookup we cannot apply additional filters.

Also, to get rid of the validation message, re-validate the field after populating it programmatically. fieldContext.validate(). In 4.0.4, this will not be required as a field will validated automatically on each change.

Posted by Meryk on 18-Dec-2015 04:22

Ok if its sorted in 4.0.4 it should be fine . We are upgrading soon anyways.

But for the additional filter, does this mean I have to do it manually ?

Thanks

Meryem

Posted by Mohammed Siraj on 18-Dec-2015 04:33

But for the additional filter, does this mean I have to do it manually ?

Yes, you will have to acheive it by writing custom code.

If fieldB lookup field is configured as a 'Picklist' then it will be realized in form pages as kendoDropdownList, you can apply filter on its datasource very similar to how we do it on a normal Picklist field. Beleive we have already discussed this in one of the forum posts related to kendoDropDownList.

Also, request you to file an enhancement request in the Ideas section for this requirement - Apply more than one filter in case of Link lookup field.

This thread is closed