on 02-20-2009 9:39 PM
Hello,
I'm wondering if someone can provide me with a document that outlines how to use the beanshell script in e-sourcing/CLM. Also, an example of an input field vlidation script would help get us on the right track.
Thanks in advance,
Kyle
Hi kyle,
An example of Input field validation can be like this..
Say If you want to check a value of field to be in between 0 and 50 then do this..
if(hasValue(fieldValue) @and (fieldValue < 0 @or fieldValue > 50))
throw doc.createApplicationException(field.getAttributeId(),"Value should be in between 0 and 50");
plz note that u need to define above script for that field (which ever field u want) in the script definition section of setup.fieldValue will automatically contian the value of that particular field.
Hope it'll help you..
Himanshu
P.S. plz award points if it helps you.,,,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your response. It's helping us get started with scripting. I was able to throw an exception but, can not seem to get the value of the field I'm trying to verify.
the following code just produces a value of null below the field I'm creating the validation for.
throw doc.createApplicationException(field.getAttributeId(),fieldValue);
If I create a Field Validation for DISPLAY_NAME and I enter 1234 in this field should fieldValue have a value of 1234?
Thanks,
Kyle
Edited by: Kyle MacDonald on Feb 24, 2009 12:58 AM
Edited by: Kyle MacDonald on Feb 24, 2009 5:18 PM
We were able to dig up the context methods and objects by looking through the contents of the this.namespace.getMethodNames() and this.namespace.getMethodNames() arrays.
The methods are
getFieldValue
createApplicationException
hasValue
setFieldValue
setAccessibility
The variables are
fieldValue
otherDoc
other_phase
current_phase
collection
session
bsh
field
doc
phase_advancing
Example that worked for us anyhow
fieldValue = getFieldValue();
if (hasValue(fieldValue))
if (!fieldValue.toString().startsWith("Lease"))
throw doc.createApplicationException(field.getAttributeId(),"Value must start with 'Lease'");
BTW documentation on this seems to be sparse.
Hi Siri,
If you are talking about budgeted/estimated cost of project template then you can write the script this way to validate :
PriceIfc budgetedValue= doc.getBudgetedValue();
PriceIfc estimatedValue=doc.getEstimatedValue();
if(hasValue(budgetedValue))
{
BigDecimal projectValue=budgetedValue.getPrice();
log("projectValue--"+projectValue);
if(totalContractValue.getPrice()<=0.0000 )
{
log("projectValue is less than or equal to 0.0000 --");
//throw error
}
}
else
{
//throw error
}
This way you can validate both whether project has price, if not would throw an error. If project has price and if it is equal then also it would throw error. Please use necessary imports.
Regards,
Kumud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kyle,
Quote: "If I create a Field Validation for DISPLAY_NAME and I enter 1234 in this field should fieldValue have a value of 1234"
Yes,the fieldValue should contain 1234
There is another method of getting a fieldVlue, that is : getFieldValue()
If you can discuss what exactly you want to do, may be I can help you..
Thanks
Himanshu Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.