- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 05:55 AM
Hello,
I have a requirement where the catalog item has 2 fields, A and B ( both of type reference), I want to build an onChange script where when a user select a value in A, field B should only populate values that are in relationship with choice in field A.
How do I achieve this? My code is currently failing.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 06:22 AM
Hi Leandre,
I too had a similar requirement, in which I had to select the Manager in 1 reference field, and his (selected manager's) related members only needed to be shown in other Reference Field.
For this, I made use of Reference Qualifier and called them in Script include.
For Manager reference field, I used Advanced reference qualifier, in Reference qualifier javascript:getManager()
Its Script include is as per the screenshot:
Similarly, to get members, used Advanced Reference Qualifier, in Reference qualifier javascript:getMember()
Members Script include is as per the screenshot:
It worked fine for me.
Please mark my answer as Correct or Helpful, if in case it resolved your query.
Regards,
Vishrut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 06:01 AM
Hi,
you can use var a=g_form.getReference("A"), now you will get entire object of field A then you can set B value from the A object by using
g_form.setValue("b",a.name)
Thamks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 06:16 AM
Hi Shantharao,
I did this, and still it is now working, would you see what's wrong with my code?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == "") {
var test = g_form.getReference("smr_model");
g_form.setValue("smr_sw_discovery_model", smr_model);
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 06:28 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == "") {
}
//Type appropriate comment here, and begin script below
var test = g_form.getReference("smr_model"); // from this line u have stored "smr_model"(A) object in "test " variable and you need to set value into B field u can use "test" object dot some field name for ex "test.name" instead of smr_mode
g_form.setValue("smr_sw_discovery_model", test.name);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 06:22 AM
Hi Leandre,
I too had a similar requirement, in which I had to select the Manager in 1 reference field, and his (selected manager's) related members only needed to be shown in other Reference Field.
For this, I made use of Reference Qualifier and called them in Script include.
For Manager reference field, I used Advanced reference qualifier, in Reference qualifier javascript:getManager()
Its Script include is as per the screenshot:
Similarly, to get members, used Advanced Reference Qualifier, in Reference qualifier javascript:getMember()
Members Script include is as per the screenshot:
It worked fine for me.
Please mark my answer as Correct or Helpful, if in case it resolved your query.
Regards,
Vishrut