Thank you Item, I know I can just chain
ifthenElse(condition,result,(ifThenElse, condition, result, (ifThenElse...)))
But it look very messy and not very ideal.
I also wanted to learn how to use this While feature as well.
I'm doing formula this for hundreds of City and their Council/Local Government name so it not very ideal chain like that method.
Currently I'm doing ifThen but it keep using the last currently formula instead of stopping once found.
Announcement
Collapse
No announcement yet.
formula break, exit, return??
Collapse
X
-
if understand, you don't need the "while"
i just tested on demo this and this can make your request :
ifThenElse( assignedUser.userName == null && billingAddressCity == 'Berlin', output\printLine('Empty et Berlin'), output\printLine('NOT Empty'), )
repeat the ifThen... and not ifThenElse as my sample for all your case
it's new in formula use "if" like php and not espoCrm Language ?
-
Here is the currently code for Formula Sandbox
Code:output\printLine(addressCity); output\printLine(description); while (description==null) { if (addressCity=='City1'||'City2') { description='123'; break; } if (addressCity=='City3'||'City4') { description='321'; break; } // some_final_logic break; // important } // CODE #2024-04-25 end output\printLine(addressCity); output\printLine(description)
When tried with City3
Looking at the Documents, I think I am meant to use Continue and break? I tried combination of it and doesn't seem to get the right formula.
Last edited by esforim; 05-04-2024, 04:47 AM.
-
EDIT, it does not work correctly! See following post and hopefully solution
Hi all, finally try this again and I think I figure it out... hopefully it work for you!
Some note, Property is an address/relationship ID, I only want to run this when it is "null" or "blank".
AddressCountry is a default address field.
Code:while (propertyId==null) { if (addressCountry=='USA') { addressCountry ='USB'; break; } if (addressCountry=='USB') { addressCountry ='USC'; break; } // some_final_logic break; // important } // CODE #2024-04-25 end output\printLine(addressCountry);
Last edited by esforim; 05-04-2024, 05:09 AM.
Leave a comment:
-
Update, upon seeing the error above, I went with this formula if anyone want to use it.
It a very basic formula being use and I don't know if it will always work as I hope it to be... maybe you see an update post some week or months in the future when I run into problem!
Nothing change except the correct field/attribute (previously I wrote "type" for some reason). So as long as my Status does not equal to "Closed", the formula will executed. When it become Closed it will no longer executed.
Code://STOP AND DISABLE FORMULA if (status!='Closed'){ // I write my formula here for example: description='hey it working' } // STOP FORMULA DUE TO CLOSE STATUS
Last edited by esforim; 04-17-2023, 08:19 AM.
Leave a comment:
-
Sorry to be a nuisance but is it literally 'break'? Something like this will work?
I just notice I used 'type!='Closed' in my first post, maybe that why it didnt work.
Secondly I notice that I have to do this twice when using while formula, would a "if" formula be more ideal?
Code:while (true) { if (status!='Open') { description='formula is running'; } if (status='Closed') { description='formula is stop running'; break; } // some_final_logic break; // important }
Leave a comment:
-
Hi all, bumping this because I need something like this.
How do you guy stop the formula from running?
I want no more formula to run when "Status==Closed", because the Case is closed...
I see some potential option but I'm not sure if it will work properly and break the formula all together...
I tried this idea but doesn't seem like it the way to go. Maybe I should use "when"? But not sure how to use the Break part:
Code://STOP AND DISABLE FORMULA if (type!='Closed'){ write my formula here } // STOP FORMULA DUE TO CLOSE STATUS
Leave a comment:
-
Hello Yuri,
do you think, as formula is beforeSave and https://github.com/espocrm/documenta...or-handlers.md
we can just do a global formula ?
if yes, it's easy to make a new formula.
if no...
Kind Regards
- Likes 1
Leave a comment:
-
formula break, exit, return??
Hi,
Is there a way to force an exit on a formula?
I could nest the code in conditionals, but the code would be simpler if a certain set of conditions were true, stop processing the formula.
Thanks,
Russ
Tags: None
- Likes 1
Leave a comment: