cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting with Beanshell in CLM

Former Member

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

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.,,,

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks for the info. We're on the right track now.

Regards,

Kyle