cancel
Showing results for 
Search instead for 
Did you mean: 

Populating the 2nd dropdown based on value selected on 1st dropdown

Former Member
0 Kudos

Hi,

I know that there is a similar post about this in the forum but it doesn't actually show how an event for the dropdown is created. I believe this would be a script that is done within the form (transaction SFP) itself, but could I please have an example please?

I did try to take a look at the standard ISR_FORM_SPTD form but there doesn't seem to be any scripts in this form.

Thanks and regards,

Adeline.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Am not so sure, how were unable to locate this script. Click on the dropdown and check in the Script editor. You will get the same script. Anyways, here is the script.

<i>// If the display value is used in the data DOM,

// re-assign the corresponding data value

if (this.rawValue != "" ) {

if (this.boundItem(this.rawValue) != "") {

this.rawValue = this.boundItem(this.rawValue);

}

}

// START OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "CHECK";

app.eval("event.target.SAPSubmit(false);");

// END OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

-


data.RequestPromotion[0].PCR_PAGE1.PCR_DE.PCRDEContent.NewScaleLevelDDL::ready:form - (FormCalc, client)

// START OF XFO CODE - DO NOT REMOVE OR MODIFY

// If this object exists, then we are not being rendered by the XML Form Agent

if ((Exists(xfa.host.appType)) and ($.bind.ref <> "")) then

// Note the rawValue and try to set the selection if it is present

// As soon as you add items the rawValue will be lost

var CurrValue = ""

// Check for a null - an empty XML node will return a null

if ($.rawValue <> null) then

CurrValue = $.rawValue

endif

var Found = 0

// the data binding may contain "$data.<root data name>" instead of $record

var DataBinding = replace($.bind.ref,Concat("$data.",xfa.record.name),"$record")

DataBinding = replace(DataBinding,"[*]")

for i=0 upto xfa.record.enum_list.nodes.length - 1 step 1 do

// Find the match. The binding value may contain "[*]"

// so remove them first

var ListBinding = replace(xfa.record.enum_list.nodes.item(i).binding.value,"[*]")

if (DataBinding == ListBinding) then

// the first two items are the name and binding attributes, then the list starts

if (xfa.host.version < 7) then // add a dummy item to work around a bug in A6

$.addItem("a","-1")

endif

$.clearItems()

for j=2 upto xfa.record.enum_list.nodes.item(i).nodes.length - 1 step 2 do

// The order is assumed to be display and then data

// if the value is null, then add the empty string

if (xfa.record.enum_list.nodes.item(i).nodes.item(j+1).value == null) then

$.addItem(xfa.record.enum_list.nodes.item(i).nodes.item(j).value,"")

else

$.addItem(xfa.record.enum_list.nodes.item(i).nodes.item(j).value,xfa.record.enum_list.nodes.item(i).nodes.item(j+1).value)

endif

if (xfa.record.enum_list.nodes.item(i).nodes.item(j+1).value == CurrValue) then

Found = 1

endif

if ((xfa.record.enum_list.nodes.item(i).nodes.item(j+1).value == null) and (CurrValue == "")) then

Found = 1

endif

endfor

// Now set the selection - omitting this step means there will be no selection

// if there is only one item in the list and no default value, we have to select the first item - Bug in Acrobat 6.02 (fixed in Acrobat 7)

if ((xfa.record.enum_list.nodes.item(i).nodes.length <= 4) and (CurrValue == "") and (xfa.host.version < 7)) then

$.rawValue = xfa.record.enum_list.nodes.item(i).nodes.item(3).value

else

// if available, set the selection to the default value

if (Found) then

$.rawValue = CurrValue

else

// otherwise: set the selection to the first item

$.rawValue = xfa.record.enum_list.nodes.item(i).nodes.item(3).value

endif

endif

// START OF CODE - TO RUN AFTER LIST HAS BEEN FILLED

// END OF CODE - TO RUN AFTER LIST HAS BEEN FILLED

break

endif

endfor

endif

// END OF XFO CODE - DO NOT REMOVE OR MODIFY</i>

This should solve your problem.

Regards

<i><b>Raja Sekhar</b></i>

Former Member
0 Kudos

Hi Raja,

i think you missed to paste the location of the script above the form ready event. So to be complete: it should be places in the exit event of the field as Javascript.

kind regards, Marijn Sponselee

Former Member
0 Kudos

Hi Raja Sekhar,

Sorry, I may have not been too detailed in my question.

I do know where the scripts are located but what I need to do for my PCR, is to populate the 2nd dropdown list based on the value selected on the 1st dropdown. I understand that this should be handled within SCENARIO_PROCESS_USER_COMMAND but firstly, I would need to create an event for the dropdown list. Could you kindly provide me an example of how this is done within the script? I believe a new event would need to be created for this dropdown and be called within SCENARIO_PROCESS_USER_COMMAND - could you please illustrate how this is done?

Thanks for your help.

Regards,

Adeline.

Former Member
0 Kudos

Hi,

I have managed to populate the 2nd dropdown list based on the value selected in the 1st dropdown list. However, I can't seem to select any value within the 2nd dropdown list. Could someone please help?

Please refer to the below for what I've done so far :

<u>Within the CLICK event in the form for the 2nd dropdown list (Javascript)</u>

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "EXPOST";

app.eval("event.target.SAPSubmit(false);");

<u>Within SCENARIO_PROCESS_USER_COMMAND</u>

CASE user_command.

WHEN 'EXPOST'.

read table special_data into ls_special_data

with key fieldname = 'EXORGUNIT'.

if sy-subrc eq 0.

clear ls_additional_data.

ls_additional_data-fieldindex = 1.

ls_additional_data-fieldname ='POSITION_KEY'.

ls_additional_data-fieldvalue = 'testkey'.

append ls_additional_data to additional_data.

clear ls_additional_data.

ls_additional_data-fieldindex = 1.

ls_additional_data-fieldname ='POSITION_LABEL'.

ls_additional_data-fieldvalue = 'testlabel'.

append ls_additional_data to additional_data.

endif.

ENDCASE.

The code to populate the 2nd dropdown list is not complete but this was just a test to ensure that I could populate the 2nd dropdown list. I currently see 1 entry in the 2nd dropdown list, which is "testlabel" but I can't seem to select this value. Is there something which I've missed out?

Thanks and regards,

Adeline.

Former Member
0 Kudos

Hi,

If i get your point correctly,

In the exit event of the first dropdown -> write the event name and call it.

In the user command write the code for the same. Thats it.

Hey select the drop down from the 'ISR controls' in the Library pallette.

uncomment the standard code that u require in the standard script.

I don see any reason to write the event in the second drop down.

If only one value is coming in the drop down, see that u r incrementing the index on adding the values to the drop down.

Thanks and Regards,

Anto.

Former Member
0 Kudos

Hey dude,

Why dont you copy and paste the standard SCRIPT of the existing dropdown except this part

// START OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "CHECK";

app.eval("event.target.SAPSubmit(false);");

// END OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

I think this should solve your problem.

Regards

<b><i>Raja Sekhar</i></b>

Former Member
0 Kudos

Hi Raj,

Where can be see the script code you mentioned in the standard form ISR_FORM_SPTD? I am new to Adobe form. Bear with me if this is a naive one.

Thanks

Former Member
0 Kudos

Hi Ricky,

You can check that out in Adobe Life Cycle Designer, It will be just above the Body Page. There will be a small window which we require to expand it manually.

And make sure that you have enabled SCRIPT EDITOR in WINDOW menu.

Regards

<i><b>Raja Sekhar</b></i>

Former Member
0 Kudos

Hi all,

I too have issue with populatind 2nd DDL but it is a bit diffetent.

I could raise exist event from first DDL and in back end BADI populated the data for second DDL. Works fine till we have list items less than 50 in frist DDL.

When there more than 50 list values, instead of drop down list a another window with value help is kicking in. When I select line from this new Value help window exit event or for that matter none of the events in first DDL works.

I dont know which ISR control is providing the functionality of this new value help and where the code is that is forking the drop down list vs value help list. We are on ERP2005 MSS 1.0 and SP's are pretty much latest.

The other turnaround option I looked at was using pre-open event in second DDL to populate the data. But event is getting triggered inconsistenly and second DDL drop down list is beaving erratic.

Here is how the code that is used in Exit event.

// START OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "VACPOS";

ContainerFoundation_JS.SendMessageToContainer(event.target, "submit", "", "", "", "");

// END OF CODE - TO RUN AFTER SELECTION HAS BEEN MADE

Did anyone faced this problem and know the solution.

thanks

Sridhar

Former Member
0 Kudos

Thanks for the reply Raj. Appreciate it. Still I am facing the issues in viewing script for drop down list icon. In the standard form ISR_FORM_SPTD, I went to layout and checked the space above body pages and expanded it manually. Nothing is there inside the space. Am i doing something wrong and also i understand that the script is for drop down and i cannot see any drop down in the layout. Could you pls help me understand about scripts and drop down more clearly.

Thanks

Ricky

Former Member
0 Kudos

Hi Sridhar,

Please tell the NW , ADS, ALCD and Reader versions you are using.

Hi Ricky,

In the script editor, select 'Event with Scripts' or 'All events' option in the Show drop down (usually present at the left). There you will find the scripting done. You may find more info on these in the help file.

Thanks and Regards,

Anto.

Former Member
0 Kudos

Anto,

Iam using ALCD 7.1 Adove reader 7.0.8 and we are on NW2004S

thanks

Sridhar

Former Member
0 Kudos

Hi,

I've still not been able to solve this issue. Could someone please help?

To reiterate, I wish to populate my 2nd dropdown list based on the value selected in my 1st dropdown list. This is what I've done so far.

<u>Within the CLICK event in the form for the 2nd dropdown list (Javascript)</u>

xfa.record.CONTROL_PARAM.ISR_EVENT.value = "EXPOST";

app.eval("event.target.SAPSubmit(false);");

<u>Within SCENARIO_PROCESS_USER_COMMAND</u>

CASE user_command.

WHEN 'EXPOST'.

read table special_data into ls_special_data

with key fieldname = 'EXORGUNIT'.

if sy-subrc eq 0.

clear ls_additional_data.

ls_additional_data-fieldindex = 1.

ls_additional_data-fieldname ='POSITION_KEY'.

ls_additional_data-fieldvalue = 'testkey'.

append ls_additional_data to additional_data.

clear ls_additional_data.

ls_additional_data-fieldindex = 1.

ls_additional_data-fieldname ='POSITION_LABEL'.

ls_additional_data-fieldvalue = 'testlabel'.

append ls_additional_data to additional_data.

endif.

ENDCASE.

Is the above correct? And are there any others steps which I've missed out? BTW, both the dropdown lists created are of type ISR DDL.

Thanks and regards,

Adeline.

Former Member
0 Kudos

Hi Adeline,

You have to put the code populating additional_data in method SCENARIO_SET_ADDITIONAL_VALUES instead of SCENARIO_PROCESS_USER_COMMAND.

The data that is appended in additional data in method SCENARIO_PROCESS_USER_COMMAND will not be available when ISR completes event and displays the screen again(PBO).

You may have noticed that user_command paramater is not available in SCENARIO_SET_ADDITIONAL_VALUES, therefore what I have done is to read value in the first variable (if the list item is selected) then populate additional_data for second field.

Simply swap your code to method SCENARIO_SET_ADDITIONAL_VALUES and it should work. Also you may enhance your code

read table special_data into ls_special_data

with key fieldname = 'EXORGUNIT'.

        • insert

if not ls_special_data -fieldvalue is initial.

****

continue your code of populating additional_data

endif.

Thanks

Sridhar

Answers (0)