IF statement in the sourceexpr property

efassettaefassetta Member Posts: 53
Hello,

i have a text control in a form, called TB

I need to set the sourceexpr property of it, in depending on the value of a field.

In other words IF a field is equal to 10 then value of TB is A, else B.

Is possible to do this?

Thank's.

Comments

  • lvanvugtlvanvugt Member Posts: 774
    What did you try?

    As far as I know any expression put in the SourceExpr property should be a value. So what can you enter:

    1. a variable (als being a field)
    2. a boolean expression like B > A as this is either TRUE or FALSE (i.e. a value)
    3. a value like 100, a, 1.0009
    4. a function that returns a value

    So this does not apply to an IF statement as an IF statement does not have a value.

    But maybe my view is too narrow. 8)
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • SavatageSavatage Member Posts: 7,142
    efassetta wrote:
    Hello,
    i have a text control in a form, called TB
    I need to set the sourceexpr property of it, in depending on the value of a field.
    In other words IF a field is equal to 10 then value of TB is A, else B.
    Is possible to do this?
    Thank's.

    Your describing your post in what I assume is a very broad/vague manner.

    This field that equals 10 is it a field that a user enters data or is it a field that is calculated?
    I don't think sourceexpr is what you're looking for here.

    If you can describe a little better (more detail) we can help you solve your problem.
    PS ca you add code or not - that's a helpful bit of info you might want to add.
  • gvolkovgvolkov Member Posts: 196
    IF variable > 10 THEN
    varaibletoshow := variable ELSE
    variabletoshow := somethingelse
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • efassettaefassetta Member Posts: 53
    Thank's for your answer.

    I try to explain better my problem.

    I made a new form based on Customer Table.

    I added on it a new text box called A.

    The value of this text box (SourceExpr Property) depends on the value of the field Phone Number in the Customer Table:

    - if the Phone Number is blank, A has to have the result of the function F1 (that is a function in a Codeunit)
    - if the Phone Number is NOT blank A has to have the result of the function F2 (that is a function in a Codeunit)

    Thank's a lot.
    lvanvugt wrote:
    What did you try?

    As far as I know any expression put in the SourceExpr property should be a value. So what can you enter:

    1. a variable (als being a field)
    2. a boolean expression like B > A as this is either TRUE or FALSE (i.e. a value)
    3. a value like 100, a, 1.0009
    4. a function that returns a value

    So this does not apply to an IF statement as an IF statement does not have a value.

    But maybe my view is too narrow. 8)
  • gvolkovgvolkov Member Posts: 196
    IF "Phone No." = '' THEN
    A := codeunit.functionone(parameters)
    ELSE
    A := codeunit.functiontwo(parameters)
    

    most likely code needs to be inserted into OnAfterGetRecord trigger
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • SPost29SPost29 Member Posts: 148
    Just put a function that returns a value into the source expression

    CheckPhoneNumber that returns whatever you want (result of if statement or whatever)
    The source expression will re-evaluate itself on each record
    Steve
Sign In or Register to comment.