ADF Groovy Expression for calculation

Hi,
I am using JDeveloper 11gR2. For a transcient attribute in a VO, I must add an expression that will calculate and return a value according to a business rule.
I.e. if 'Standard' then column a * 0.3 or column b * 0.3
           elsif 'Premium' then column c * 0.3
           else 'Luxury' then column d * 0.3 Of course, using the appropriate Groovy expression. Does anyone have an example I could try?
Thanks!
Edited by: user545194 on 02.02.2013 07:28

for example if att is the attribute that you want to calculate and it depend on val attribute
the groovy exp is done on att
if(val=='Standard') return a * 0.3
else if(val=='Premium') return c * 0.3
else if(val=='Luxury') return d * 0.3
you must add attribute val, a, c ,d to the dependent attribute
hope it helps
Fakhri

Similar Messages

  • Re:Groovy Expression for time

    Hi All,
    Iam using Jdeveloper 11.1.2.3.0 ,my requirement is that :Groovy expression for time
    Can any one send me the above requirement
    Thanks,
    Sandeep

    What time?
    Yesterday noon?
    Now?
    You need to give us a use case.
    Check out GroovyCookbook: Dates and Times
    Timo

  • Multilingual Expression for Calculated fields

    Hi all,
    I need to write an expression for a multilingual Calculated field.(The calculation need to take the logon language into consideration). When looging onto the Console however and selecting languages the set languages are not auto selected as it does for Validations. The only fields available for selection is the Primary language fields.
    Is their a way to create a multilingual Expression for Calculated fields and how can I go about it?
    Thanking You
    Chris Huggett

    Hello Chris
    That functionality is not supported in SAP MDM 7.1(5.5)
    You cannot modify from validation filed values by language different than your connection language.
    You can do it manually in Data Manager or during import.
    As usually you can use MDM API for that activity.
    Regards
    Kanstantsin Chernichenka

  • Groovy expression for fetching current user details

    I have created a view object that retrieves user details from the database. Also for dynamically getting the details of the current user logged in i have defined a bind variable currentUser and the default expression is adf.context.securityContext.userName.When i give the fixed literal value as user name the details are fetched. However details are not fetched when i use the groovy expression. Can i get some help on this please.
    Regards

    details are not fetched when i use the groovy expressionby using groovy you cant the details
    i cant get you, is this you question?
    some hints, here
    groovy expression as default value in a Entity's Field Problem

  • Groovy expression for error message in validation

    hi...
    using groovy expression i want to display a dynamic error message...(ie.i have a date field the date cant be a past date..if i enter the past date like (02-04-2012 )the error message should display with this date)

    For a validation rule on an entity attribute, you can use a Groovy expression to decide whether
    an error or a warning message should be displayed using the following expression:
    adf.error.raise("THIS_IS_AN_ERROR_MESSAGE")
    adf.error.warn("THIS_IS_A_WARNING_MESSAGE")
    In your case, you can customize the message and access the date attribute in the message as source.HireDate(Assuming HireDate is the date attribute)
    Hope it helps.

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • Groovy expression for column total not working

    I want to show the column total. I have created a view accessor on the view object and a new attribute of Transient type and set its expression to AccessorName.sum("columnName").
    But its values is never calculated when I test the view object.
    Any help on this is appreciated.
    PS: The total is calculated correctly when the view object does not have any bind variable. Once I add a bind variable the column total is not being calculated. I have verified this. Any help on how to handle this issue ?
    Using JDev 11.1.2.3

    If you could have elaborated a bit more it would have been useful , but apparently i can think of few thing which you could double check.
    1. The transient attribute type is Number.
    2.If the column exist on the same view object then you should write sum("ColumnName") else you have to create a view accessor on the VO and set its expression to AccessorName.sum("columnName").
    Hope it helps !!
    Else you could elaborate a more for us to help
    Thanks
    Soumya.

  • ADF : Groovy Expression

    Hi
    Is it possible to reference the current entity object name using groovy? I would like to get the entity name in a validator to customize the error message.
    I currently have a validator and an error message with two placeholders,
    Attribute {0} is not allowed to be referenced on {1},
    Placeholder {0} is being resolved using, source.hints.AttributeName.label, I cannot find a suitable expression to resolve placeholder {1}.
    Thanks.

    Hi,
    Can you try
    adf.object.getDefinitionObject().getAliasName()-Arun
    Untested

  • Boolean expression for calculation problem

    Hi experts,
    I have following Keyfigures arranged in my Report:
    A  | B | AB | C | D | CD
    *A,B,C,D are key figures in column
    Now the user has demanded that they want to see only positive numbers in that Report and add all negative numbers in one column
    Desired:
    A (Only More than 0) | B (Only More than 0) | AB | C (Only More than 0) | D  (Only more than 0) | CD | ABC+D(where A,B,C,D are less than 0) * -1
    I know I have to do it using formula and boolean expression but dont know how.

    Create new Calculated KFs using Boolean operators  and hide original KFs.
    (A > 0) * A
    (B > 0) *B ....
    Similarly others 
    ((ABCD) <0)*(ABCD)  for -ve values
    Jaya

  • (Groovy Expression) Get the no. of days between two dates

    Hi All,
    I am using ADF-BC-11g to create an entity object with 2 specific columns ActualDate and EstimatedDate both of Date type. I also want an additional field DaysBetweenTwoDates showing the difference between these two dates. Hence, I add another attribute DaysBetweenTwoDates in my entity object and after removing the Persistent property, I modify the expression field as ActualDate - EstimatedDate. When I test my AM, I get an error as below:
    *(oracle.jbo.JboException) JBO-29000: Unexpected exception caught: groovy.lang.MissingMethodException, msg=No signature of method: java.sql.Date.minus() is applicable for argument types: (java.sql.Date) values: {2009-04-01}*
    Can anyone please tell me how to achieve the same?
    Please note that I can not add a new column DaysBetweenTwoDates in the table nor can I have a new VO attribute subtracting and storing the difference as there are some logical and refreshing constraints.
    Any suggestions would be really helpful.
    Thanks
    Neeraj

    Thanks John,
    Oops...I did not think on this ground at all. Thanks for directing towards right direction. However, just to know, is that possible anyways thorugh groovy expression? Do we have any docs where we can search for the functions available in groovy expression?
    Regards,
    Neeraj

  • Accessing AppModuleImpl methods from Groovy expressions?

    From a VO View Criteria bind variable I'm attempting to call an accessor (aka. getValue) in it's parent AppModuleImpl, via a Groovy expression. I thought I could do something like:
    ((model.AppModuleImpl)object.getApplicationModule()).getValue()
    ...but at runtime I'm getting an error that Groovy doesn't know model.AppModuleImpl.
    I must be missing something here. Does anybody have the Groovy syntax for calling methods in the parent AppModuleImpl please? I've searched Grant Ronald's ADF Groovy whitepaper with no success, and I haven't found an example on these forums either.
    With thanks,
    CM.
    PS. JDev 11.1.1.2.0, ADF BC + ADF Faces RC

    Hi,
    I am not sure but may be you found this post useful http://andrejusb.blogspot.com/2010/01/storingaccessing-objects-in-adf-bc.html
    one more thing i did lately you can try if it works
    I created Method in AppModuleImpl class and called it in VOImpl class with AM object and then assigned it as expression to the attribute value in VO it should work for Bind variable value as well
    //Method in AM
      public String sayHello(){
        return "Hello World";
    //Method in VOImpl
      public String getHelloFromAM(){
        AppModuleImpl am = new AppModuleImpl();
        return am.sayHello();
    //Attribute "HelloTEXT" default value
    adf.object.getHelloFromAM()Hope it the same thing you are looking for
    Baig
    Edited by: BaiG on Jul 12, 2010 1:02 PM

  • Using groovy expressions to get a value of the current row

    Hi,
    I have a bounded task flow. The first step in the flow is calling an ExecuteWithParameters on one of my views. Based on the result of this query, I want to go to either Page1 or Page2.
    So I have a router. I first tried to route based on whether or not the result of the query contained only one row. That worked fine. But I want to add a condition to that.
    Basically, if the query returns one row AND that row has an attribute named 'Noc' == 1, then I want to go to Page2. Otherwise, go to Page 1.
    Right now to get the estimatedRowCount I am getting the iterator from the pageDef file created for my ExecuteWithParams object. To see if 'Noc' == 1, I tried this:
    #{data.rcl_view_reimbCode_search_results_task_flow_reimbCode_search_results_task_flow_ExecuteWithParamsPageDef.ReimbCodeSearchView1Iterator.currentRow.getAttribute("Noc") == 1}
    But it is complaining of grammar issues.
    What is the best way to go about getting the value of my attribute in a groovy expression?
    Thanks,
    Joel

    Hi,
    the best way is to use a managed bean reference
    1. create a binding for the router
    2. Expose the queried iterator in the PageDef file
    3. write a managed bean that accesses the binding
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentEntry();
    DCIteratorBinding iter = bindings.get("NameOfIterator");
    // i) get estimated row count
    // ii) get attribute value
    //iii) evaluate
    // iv) return true/false
    Reference the managed bean from the router
    Frank

  • MultiRowEdt-JBO-35000: Cant resolve spel expression for attribute {0}in{1}

    Hi All,
    i'm in the process of completing the mutli row edit tutorial that I downloaded from this site. I'm using 10.1.2, adf bc and jsp's.
    I've competed the tutorial and am getting an error JBO-35000: Cant resolve spel expression for attribute {0} in {1} .
    I've checked that my attribute names are the same as the VO and have created a BeanInfo class to handle the mapping of these attributes. All appears as it should, so not sure where to go from here.
    Any ideas would be gratefully received.
    Thanks in advance,
    Newbw

    hello,
    I'm facing the same problem in implementing mutli row edit tutorial.
    I'm using JDeveloper 9051.
    Can u please tell me how did u solve ur problem as i didnt understand what u've posted on forum "spelt my VO wrong".
    Please reply. waiting
    Thanks in advance
    Mina

  • EL expression for maximum length of column of underlying EO

    Hi all,
    I am using ADF Faces with ADF BC as the model layer. I have a simple inputText component on the screen that shows 32 characters (columns property = 32). The underlying database table can hold 128 characters. Is there any EL expression that I can use for the maximum length? I have tried the EL expression builder, but I don't see any property that looks promising (#{bindings.fieldname.<something>} is what I'm looking for)
    Thanks,
    John

    Chris,
    In 10.1.3.2, we already automatically drop an EL expression for the Columns property that is bound to the Display Width hint.
    It will look like:
                <af:inputText value="#{bindings.Dname.inputValue}"
                              label="#{bindings.Dname.label}"
                              required="#{bindings.Dname.mandatory}"
                              columns="#{bindings.Dname.displayWidth}">
                  <af:validator binding="#{bindings.Dname.validator}"/>
                </af:inputText>If the developer has not supplied a custom value of Display Width, then it defaults to the maximum length of the attribute.
    If you have provided a custom Display Width hint that is shorter than the maximum length, then you can reference the maximum length by using the precision property of the attribute definition, as shown in the EL expression for maximumLength below.
                <af:inputText value="#{bindings.Dname.inputValue}"
                              label="#{bindings.Dname.label}"
                              required="#{bindings.Dname.mandatory}"
                              columns="#{bindings.Dname.displayWidth}"
                              maximumLength="#{bindings.Dname.attributeDef.precision}">
                  <af:validator binding="#{bindings.Dname.validator}"/>
                </af:inputText>

  • Groovy Expression Issue

    Hi,
    JDeveloper version: 11.1.1.3.
    I am setting the bind variable value using the below Groovy expression but the issue it is always setting the value "anonymous" instead of logged in user.
    viewObject.DBTransaction.session.userPrincipalName.toUpperCase()
    Note: Same is working fine in 11.1.1.2 version.
    Thanks.

    Hi,
    Thanks for the reply.
    Document says the following but I am not sure how to use incase of setting the bind variable for a VO.
    Application Module Returns Anonymous User After Logged In (9546149)
    Web applications using getUserPrincipalName() from ApplicationModuleImpl or SessionImpl may get 'anonymous' after user already logged in. Use ADFContext.getCurrent().getSecurityContext().getUserName() instead. Entities with histoty column kinds Created By and Modified By should override getHistoryContextForAttribute() in the entity impl class as follow:
    protected Object getHistoryContextForAttribute(AttributeDefImpl attr) {
    byte historyKind = attr.getHistoryKind();
    if ((historyKind == AttributeDefImpl.HISTORY_CREATE_USER) ||
    (historyKind == AttributeDefImpl.HISTORY_MODIFY_USER))
    Thanks.

Maybe you are looking for