cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting default values in MDK Asset Manager

sschuetz
Explorer
0 Kudos

We are trying to do a simple enhancement to pre-select a default value on the ControlKeyLstPkr control of WorkOrderOperationCreateUpdate.page

The Value property of the ControlKeyLstPkr control is set to a new rule with the following code:

export default function WorkOrderOperationControlKey(context) {		
                var page = context.getPageProxy().getControl('FormCellContainer');
		var targetList = page.getControl('ControlKeyLstPkr');
		var binding = targetList.getBindingObject();
		binding.ControlKey = 'PM01';
	        return targetList.setValue(binding.ControlKey);
}

We have verified the rule is executed and PM01 is in the list, but the default value is not set. Any thoughts on what we are doing wrong here?

ashishjain14
Employee
Employee
0 Kudos

What version of MDK do you use?

sschuetz
Explorer
0 Kudos

For this test we were using MDK Client version 4.1.5 with SAM 1911, and also tested with the App Store version that is build on 2005.0.1

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

sschuetz

Were you able to resolve your issue? If any of the below responses helped you, then please mark the helpful answer by accepting it OR post an answer so others might benefit from your findings.

Regards, Jitendra (SAP Community Moderator)

Accepted Solutions (0)

Answers (1)

Answers (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Scott,

For your rule, to set the default value the rule should be returning the actual value "PM01" in this case. Since the page is used for both Create and Update, your rule will need to determine which mode the page is being used for and either return the resolved value of {ControlKey} for edit or just return PM01 for create.

--Bill

sschuetz
Explorer
0 Kudos

Bill - we switched it to just return the string value 'PM01' (just testing the "add" scenario for now) but still no default is selected. I'm wondering if there is something else about the way the control is defined that doesn't allow the value to select.? The alert does pop up so we know it is getting to the case.

case 'ControlKeyLstPkr':

alert("WorkOrderOperationCreateDefault.js function");

return 'PM01';

This was changed in the WorkOrderOperationCreateUpdateDefault.js as that seemed like a more appropriate place to set the value.

Scott

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Scott,

Your rule is using the correct method to set a value for the list picker and is actually working as expected. However, in the case of the Asset Manager application, in the OnLoaded event of the WorkOrderOperationCreateUpdate.page the default code is setting a default value for the Control Key that overwrites the default value from your rule.

The SAM 2005 code sets the Control Key to the Parent Work Order OrderType value. If the Order Type is not a valid choice in the Control Key picker the default will be blank. But if the parent work order type is PM01 then the Control Key will be defaulted to PM01.

Hope this helps clarify.

--Bill