cancel
Showing results for 
Search instead for 
Did you mean: 

Disable SAP MDK app field based on the current Page field value

elavarasanselvam
Explorer
0 Kudos

Hi All,

I am using the latest SAP MDK SDK 3.2.0 version and trying to disable or hide a field, based on another field value entered/selected by the user in the same edit page of an MDK application.

Trying to get this dynamically. For example, I have two simple property fields in a Form cell edit page:

1. FCCountry

2. FCName.

And when I change the ‘FCName’ field value to ‘Carolyn’, ‘FCCountry’ must get disabled for editing. The below rule is written in the ‘Iseditable’ property of ‘FCCountry’ field, but does not work as expected. Please help with your valuable suggestions.

editpage.png enablerule.png

Accepted Solutions (0)

Answers (2)

Answers (2)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

aj100 To toggle the value you should include an else block in your rule to enable if the value does not equal 'Carolyn'

igor_sangulin
Explorer
0 Kudos

Something like this should work, put this function in onValueChange event of your FCName control. I'm just not sure it is the best way...

export default function setFCNameEditable(clientAPI) {
  var fieldValue = clientAPI.evaluateTargetPath('#Page:FormEditLink/#Control:FCName/#Value');
  var element = clientAPI.evaluateTargetPath('#Page:FormEditLink/#Control:FCCountry');
  if (fieldValue == 'Carolyn') {
    element.setEditable(false);
    element.redraw();
  }
}
elavarasanselvam
Explorer
0 Kudos

Hi Sangulin,

Thank you for the prompt response.

In the above rule, the 'fieldValue' variable takes the current page 'FCName' field value, but the setEditable() function does not set 'FCCountry' field as editable/disabled based on the current page 'FCName' field value.

Also, tried to get the control name using the page proxy in 'onValueChange' event, as shown in the below link. This also fails. Please let me know if you have any suggestions here.

setenabledrule.png
igor_sangulin
Explorer
0 Kudos

Sorry but this code works for me. Check:

- did you put this code in FCName onValueChange event?

- check targetpaths for field and control

- did you do redraw()?

elavarasanselvam
Explorer
0 Kudos

Hi Sangulin,

I just tried again and found the ‘FCCountry’ field gets disabled, when I delete the existing ‘FCName’ value ‘Carolyn’ in edit page and type the name again. And when I change the name again to some other name, the ‘FCCountry’ field remains disabled for edit. Is there a way we can switch the ‘FCCountry’ field property between enabled or disabled, each time we edit the ‘FCName’ value?

Again, thank you for the inputs.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

AsherAnn ElavarasanSelvam

Were you able to resolve your issue? If so, please post an answer so others might benefit from your findings.