Announcement

Collapse
No announcement yet.

IfThen with many conditions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IfThen with many conditions

    Hi,
    i have made an Entity to make an approval process.
    In the Formula i have many conditions to check.
    I want to ask if this is even possible, or did i make to many if conditions?

    Code:
    // CN certified und prüfung CN Summe
    IfThen(
    [B]status == 'certified' && intstatus == 'accepted' && cnrequestoruid != modifiedBy.userName,[/B]
    cncertifier = string\concatenate(modifiedBy.firstName, " ",modifiedBy.lastName);
    intstatus = 'certified';
    ifThen(cnsum < 100,
    message = 'Prüfung und Freigabe durch einen Teamleiter notwendig'
    );
    ifThen(cnsum >= 100 && cnsum < 500,
    message = 'Prüfung und Freigabe durch einen/eine Supervisor/in notwendig';
    entity\addLinkMultipleId('teams', '5ed113eed458b9345')
    );
    ifThen(cnsum >= 500,
    message = 'Prüfung und Freigabe durch die Geschäftsführung notwendig';
    entity\addLinkMultipleId('teams', '5e15f34a2d1230fab')
    );
    cncertifierdatetime = datetime\now();
    cncertifieruid = modifiedBy.userName
    );
    Is this from the Syntax correct and possible? Or are there too many things in the bold line?

    regards Jens

  • #2
    From my experience, I do not see this having too many conditions. I myself made a formula today with 20 conditions and that works. I recommend to layout the code a bit more readable, like this:

    Code:
    // CN certified und prüfung CN Summe
    IfThen(
    [B]     status == 'certified' && intstatus == 'accepted' && cnrequestoruid != modifiedBy.userName,[/B]
          cncertifier = string\concatenate(modifiedBy.firstName, " ",modifiedBy.lastName);
          intstatus = 'certified';
    (this last line is not correct, you have to close the ifThen):
    intstatus = 'certified'
    );


    Code:
    ifThen(
          cnsum < 100,
          message = 'Prüfung und Freigabe durch einen Teamleiter notwendig'
    );
    and so on. This layout lets you see potential errors easier. Whenever the formula does not work, see the log file in the data/logs folder.
    Last edited by shalmaxb; 11-16-2020, 10:30 PM.

    Comment


    • #3
      Hi,
      thanks for your Support and sorry for the late Response.
      Good to know that complex conditions are possible so i know the problem ist in the Code

      Comment

      Working...
      X