sugar logic function: strReplace()

Hello there,

anybody please help with the strReplace?

I want to replace two characters inside a word: " " and "-" via Studio-->module--->fields---->edit formula(using logic function).

But when I write:  strReplace([" ","-"],"",$field)  it doesn't work....

How can I do that, please?

One more thing, if I will repeatably use one calculated result, can I create a variable there? Like this: 

$t = strReplace(" ","",$field)

strlen($t)

it looks like, I will get error...

Thanks in advance for any help!

Parents Reply Children
  • You can create custom sugarLogic formulas by reviewing this article. You can understand how to build a regexp in js layer this way.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • ([0-9]+)

    that reg expression should work for searching numbers... you may try it out here: https://regexr.com/ 

    Could it be an option to extend Sugar with the new Sugar Logic functions to solve the task?

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • Thank you very much, Dmytro.

    I’m not sure how to extend sugar... I just have an admin role and our instance is on cloud. It seems I can’t modify php file which I’m not familiar with, neither....

    please bear with my naive question: which language is the Studio—>sugar Logic function, is it php?

    Because when I search strReplace, it seems it’s str_replace....

  • Sophie,

    DevClub is a forum for developers that develop Sugar's new functionality or customize the current one with code developments - with JS and PHP.

    AFAIK Sugar Logic is not a developer's language however as for me it looks like a programming language.
    From my non-developers perspective, it is a special format for setting up formulas for Calculated fields (which are read-only fields in SUgar)

    But the main challenge is that, if I understood Andre correctly, is that out-of-the-box Sugar Logic cannot be used to solve your task, and Andre suggests extending SUgar with a new Sugar Logic function so that you could employ it then

    Cloud instance is not an obstacle for SUgar development, therefore, if you are not a developer, you may hire a developer to extend Sugar first - if you decide to follow this way.

    But if you prefer not to develop SUgar, you may clear out data in Excel yourself then activate validation to keep phones data clear in the future.
    Once the data is cleared in your CRM, you might be in a position to perform filtering via API endpoints without additional  on-the-fly data transformations that may affect performance

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient