Technical Blog Post
Abstract
Make Attribute as Required in Service Offerings
Body
Problem Description
Make an offering field mandatory depending on the value in some other field.
Example:
Lets take two attributes ALNVALUE1 and ALNVALUE2 used in an offering
ALNVALUE1 has an ALN Domain (LOOKUP) associated with it. The domain LOOKUP has values ‘Yes’ and ‘No’
ALNVALUE2 should be mandatory when ALNVALUE1 is set to 'Yes'. If ALNVALUE1 is set to 'No' then field ALNVALUE2 should not be mandatory.
Solution
Associate a validation script to the offering attribute.
Configuration Steps
In 'System Configuration -> Platform Configuration-> Automation Scripts', click on action Create -> Script from ‘More Actions’.
The script is created with the following details:
- Script: MAKEFIELDREQUIRED
- Description: Make a field Required
- Log Level: ERROR
- Active: Selected
- Script Language: jython
- Source Code:
from psdi.mbo import MboConstants
from psdi.util import MXApplicationException
from psdi.mbo import MboConstants;
from psdi.mbo import Mbo;
from java.lang import String;
val1 =offeringAttributes.getValue("ALNVALUE1")
if (val1 == 'Yes') :
offeringAttributes.getMboValue("ALNVALUE2").setRequired(1);
else :
offeringAttributes.getMboValue("ALNVALUE2").setRequired(0);
rc = 1
The automation script is created as shown below:
Now attach this validation script to the offering as shown below:
As you can see from the above screen shot the validation script is attached to INPUT1 and the attribute INPUT2 becomes mandatory when the attribute value of INPUT1 is set to 'Yes'.
UID
ibm11129617