cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByKey field current context

Former Member
0 Kudos

Hi everyone.

How can I get the display text of the current selection in DropDownByKey field?

My selected key is a string but I could'n find the way of doing this.

Thanks a lot for your help,

Sara E.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Gopi.

Thanks for your help, I did'n want to do a loop to find the value because I knew that in a field I have to have the value but I didn't know how to do that.

With Armin indications I did the following (I don't know if it is the best code, but I works):

MaktxKey is the selected key in the layout - Type string

ISimpleValueSet mmm = wdContext.currentContextElement().node().getNodeInfo().getAttribute("MaktxKey").getSimpleType().getSVServices().getValues();

mmm.getText(wdContext.currentContextElement().getMaktxKey()) -> It is a string with the display text of the current selection.

Former Member
0 Kudos

Hello Sara,

your code is ok but could be made slightly better (assuming that the context attribute "MaktxKey" has been created at design-time):


ISimpleValueSet values = wdContext.getNodeInfo().getAttribute(IContextElement.MAKTX_KEY)
  .getSimpleType().getSVServices().getValues();
String text = values.getText(wdContext.currentContextElement().getMaktxKey());

Armin

Former Member
0 Kudos

Thanks a lot Armin.

You are right, it is better.

Former Member
0 Kudos

Hi,

You can use the below sample code.

int iCountry =wdContext.nodeCountry().size();

String sCountryCode = null;

String sCountry = null;

String sCountryText = null;

// sCountry is the current country selected in the drop down.

sCountry = wdContext.currentEntry1DataElement().getCountryCode1();

for (int i = 0; i < iCountry; i++) {

sCountryCode =

String.valueOf(wdContext.nodeCountry().getCountryElementAt(i).getLand1());

sCountryText =

String.valueOf(wdContext.nodeCountry().getCountryElementAt(i).getLandx());

if (sCountry.equals(sCountryCode)) {

wdContext.currentEntry1DataElement().setCountryText1(sCountryText);

}

}

Thanks,

Gopi

Former Member
0 Kudos
Former Member
0 Kudos

Armin, thanks so much for your indications, it is working now.