cancel
Showing results for 
Search instead for 
Did you mean: 

Copy input box field value to a Context attribute or a Temp variable

Former Member
0 Kudos

Hi firends i am a novel in WDJ,

i have a Input box on the view having with "ID = pernr" , now in the runtime it carries a value i want to pass this value to another context attribute "ctx_pernr" or a temp variable .

once i get the value in ctx_pernr i will use it for further processing and validations, please suggest what must i write?

eg.

wdContext.currentContextElement().setCtx_Pernr(what should i write here to capture the value from above input box? )

Accepted Solutions (1)

Accepted Solutions (1)

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Jack,

Above code gets the value from a table. If that is not required and lets assume you have 2 context attribute One and Two. Attribute One is mapped to an input field. The value you get in the input field should be passed to attribute Two.

so, wdcontext.currentcontextelement().setTwo(wdcontext.currentcontextelement.getOne());

Is this what you want?

Regards,

Shilpa

Former Member
0 Kudos

yes Shipla taking on this example

of 2 context attribute One and Two.

Attribute One is mapped to an input field --> here the value of this attribute is

(Zpms_Master_Input.Output.It_P9009.Employee_Code)

This value i want to pass in attribute Two whose value is (ctx_Pernr).

so first attribute is a table attribute you are correct i get i now , it needs to be copied to 2nd attibute which is a simple attribute.

wrote the follwoing code:

int newsize= newsize-1;

for (int i=newsize; i >=0 ; i--)

{

IPrivateRelOverview.IIt_P9009Element curElement = wdContext.nodeIt_P9009().getIt_P9009ElementAt(i);

wdContext.currentContextElement().setCtx_Pernr(curElement);

}

SetCtx_Pernr in last line is coming is compilation error saying "the method ctx_pernr(string) is the type IPrivateRelOverview.IContext Element is not applicable for the arguments IPrivateRelOverview.IIt_P9009Element"

Edited by: Jack on Dec 7, 2011 3:55 PM

Former Member
0 Kudos

Hi Jack,

If you want to copy the value contained in the inputfield of the table on change of row selection. You may use the below code.

onAction of table lead selection:

wdcontext.currentcontextelemt.set<var>(wdcontext.currentnode<name>element().getemployeecode());

Make sure you set the table lead selection property to single.

Regards,

Mahesh

Former Member
0 Kudos

Dear Mahesh Thanks you made my day

On the Table -> "onLeadSelect" event i create a action "onActionTableLeadSel"

here i wrote the follwoing code.

wdContext.currentContextElement().setCtx_Pernr(wdContext.currentIt_P9009Element().getEmployee_Code());

and it worked , i was able to copy the Tbale field value to the new Input box, i also used it for further processing (delete) and it works now

@ Shilpa thanks for your continued help and guidance

Former Member
0 Kudos

One more question now i have to lead select to copy the value in the input box,

i want it ideally at init / page load

what should i write at init to auto select the first table value so that it gets copied in ctx?

Former Member
0 Kudos

You can use the same code.

regards,

Mahesh

Answers (4)

Answers (4)

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Jack,

You can write the same code in int mehod. it works fine.

Best Regards,

Shilpa

Former Member
0 Kudos

Hi if i call the same code in wdInit() it is not filling the value in the 2nd iput box,

any hints?

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Jack,

Use wdContext.currentContextElement().setPernr(curElement);

Here pernr is the value attribute mapped to inputfield. CurElement is the value of teh table row you have selected.

Regards,

Shilpa

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Jack,

Can you please clarify. Do you want the value you enter in input field to be passed to another attribute?

Your input field will be mapped to a context attribute which will store the value you enter.

Regards,

Shilpa

junwu
Active Contributor
0 Kudos

if you bind this input field with an context attribute A, you just have to get it

wdContext.currentContextElement().getA()

Former Member
0 Kudos

The input Box is already binded with a table field" employee code" , when i click on different rows the input box values changes as per the employee code in the table .

at the runtime my input box carries dynamic value,

i want to use this input box filed value for further processing by copying in another ctx_pernr.

Edited by: Jack on Dec 7, 2011 2:36 PM

Former Member
0 Kudos

wdContext.currentContextElement().setCtx_Pernr(i must put the value of the input box i mentioned here )

so that my ctx_pernr is ready for use.

Note: Input Box Id = Pernr and Value = "Zpms_Master_Input.Output.It_P9009.Employee_Code"

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Jack,

The employee code is an attribute in Table node. It can have 1-n number of values. Hence everytime you select a different row, the input field will take the value assigned in that row. This is the code you can use get value of the selected row.

int size=wdcontext.nodetable.getsize();

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

IPrivateView.ITableElementsElement curElement = wdContext.nodeTableElements().getTableElementsElementAt(i);

wdcontext.currentcontextelement.setinutfield= curElement ;

}

Regards,

Shilpa

Edited by: Shilpa Shankar on Dec 7, 2011 10:16 AM

Edited by: Shilpa Shankar on Dec 7, 2011 10:16 AM

Former Member
0 Kudos

Hi shilpa thanks for your guidance...

please check if i am writiing it properly

/////IPrivateView.ITableElementsElement curElement = wdContext.nodeTableElements().getTableElementsElementAt(i);

IPrivateRelOverview.IIt_P9009Element curElement = wdContext.nodeIt_P9009().getIt_P9009ElementAt(i);

//////wdcontext.currentcontextelement.setinutfield= curElement ;

wdContext.currentContextElement().set --> Here after i write .set i cant find the input field name -- how do i identify the input box, i assumed it would have shown something like .setPernr (since input field id is = Pernr)

Former Member
0 Kudos

is it not possible that the final value i get , i can put in

wdContext.currentContextElement().setCtx_Pernr(----HERE----) so that i can use the context??

Former Member
0 Kudos

Shilpa i think there is some confusion,

is the looping really required ??

because i want to copy the input box value to a context .....

this input box is getting value from a table ...but i think it is irreleven of from where it is getting value...

at the end of the day any value it gets at the runtime i must be able to copy that value to a context ctx_pernr isn't it ??