Before Save Custom Script Repeated Every Time (After Save)

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • rabii
    commented on 's reply
    you are right, it should be name = string function.

  • ChrisSka83
    commented on 's reply
    I actually meant the conclusion

    name=string\concatenate(name, ' ', “INC”);,
    name=string\concatenate(name);

    So that the formula knows in which field the string\concatenate is executed.
    Or does this also work without “name=” ?
    I haven't tried it yet, but I always build my formulas this way.

  • rabii
    commented on 's reply
    Correct the string/contains should check the name instead. i have fixed the code above.

    Thanks

  • ChrisSka83
    replied
    Hy rabii ,

    in case I'm wrong, but isn't “name=” missing ?
    ->
    if(entity\isAttributeChanged('lEGALFORM') && !string\contains(lEGALFORM, 'INC')){
    name=string\concatenate(name, ' ', “INC”);,
    name=string\concatenate(name);
    }​

    Leave a comment:


  • rabii
    replied
    which version of espocrm you have ?

    Just to confirm to avoid having the code executed repeatedly you can add some condition which triggers the code. in the code i have shared above, the result will be executed when condition is met. the legalform field changed and name doesn't contain INC.

    It should work fine in custom formula script.

    Leave a comment:


  • Jacksii
    replied
    Originally posted by rabii
    Try this

    PHP Code:
    if(entity\isAttributeChanged('lEGALFORM') && !string\contains(lEGALFORM, 'INC')){
    string\concatenate(name, ' ', "INC");,
    string\concatenate(name);
    } 
    


    HEY,
    This Code is NOT working for me on before save custom script formula section.

    Leave a comment:


  • rabii
    replied
    Try this

    PHP Code:
    if(entity\isAttributeChanged('lEGALFORM') && !string\contains(name, 'INC')){
        name = string\concatenate(name, ' ', "INC");
    } 
    
    Last edited by rabii; 04-14-2025, 10:14 PM.

    Leave a comment:


  • Before Save Custom Script Repeated Every Time (After Save)

    Hey,
    I am creating a CODE for Before Save Custom Script, where COMPANY NAME LEGAL FROM IS EQUAL TO INC, than COMPANY NAME MUST BE ABC INC,

    But when i am update any fields of that company every time it is ADDED INC at the end of the company like ABC INC INC INC

    here is the code;

    name = ifThenElse(
    lEGALFORM == 'INC',
    string\concatenate(name, ' ', "INC");,
    string\concatenate(name);
    );

    how to stop the INC REPEATED AT Before Save Custom Script.

    Thank in Advance




Working...