cancel
Showing results for 
Search instead for 
Did you mean: 

Getting values from other fields inside open UI

Former Member
0 Kudos

Say you have a custom WPF definition for a string edit field.

Inside the C# code how would you get the value for another field or property for use in your custom control at runtime?

Accepted Solutions (1)

Accepted Solutions (1)

jason_latko
Advisor
Advisor
0 Kudos

Riley,

Pass up that value as an Agentry Value to the control.  Agentry Values are a sub-section of the External Value tab on the screen field you are extending with OpenUI.  The Agentry Value must be set via a rule, and will be evaluated at runtime when the OpenUI control is created.  Then from your C# code on WPF, you must create an instance of the Agentry interface you are extending, then call a method to retrieve the AgentryValue that you defined and set on the screen control:

IAgentryControlViewModelStringDisplay viewModel;

viewModel = this.DataContext as IAgentryControlViewModelStringDisplay;

string str = viewModel.GetAgentryString("TEST");

The above will return the AgentryValue you set for "TEST" on the screen control.

Jason Latko

Senior Product Developer at SAP

Former Member
0 Kudos

Does it have to be the the Control View you are extending?  What if I went:

AgentryClientSDK.IAgentryControlViewModel vm = DataContext as AgentryClientSDK.IAgentryControlViewModel;

            string blob = vm.GetAgentryString("blobValue");

Even though I extend say ICustomAgentryControl

Also the Agentry value has to be set by a rule?

jason_latko
Advisor
Advisor
0 Kudos

Riley,

Picking the IAgentryControlViewModel should probably work for you, but you will need to experiment.  Yes, the Agentry Value must be set via rule.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Thanks for the help Jason.

jason_latko
Advisor
Advisor
0 Kudos

Riley,

You are welcome.  Please mark the question as answered so others can find it easily.  Thanks!

Jason Latko - Senior Product Developer at SAP

Answers (0)