Remove space if a variable is empty

Hello,

I am trying remove the space if the variable is empty using the below expression

{{replace(ifempty(26.org_id.name; ); space; emptystring)}}
{{11.Salutation.label}}{{11.first_name}} {{11.last_name}}
{{Address}}

So, if org_id is empty, i don´t want a space there. I want it like shown in the below example.
(if there is an organisation name)
Organisation Name
Mr ABC
Address

(If there is no organisation name)
Mr ABC
Address

How can i remove the space, if there is no organisation name in this case?

Thank you!!

Welcome to the Make community!

You only add the newline if it is NOT empty.

{{if(length(26.org_id.name) > 0; 26.org_id.name + newline; emptystring)}}{{11.Salutation.label}}{{11.first_name}} {{11.last_name}}
{{Address}}

2 Likes

Hey,

Thank you!!

But still i am getting a empty line if there is no value in no Org_id.


image

Does emptystring need a space or newline??

You also need to delete/backspace any newlines or spaces you have typed in after the brackets and the name.

As you can see in my screenshot, they are all on the SAME LINE.

2 Likes

Yes i have inserted everything on the same line. Since, Organisation:Name tag is big, the line cannot accomodate the below tags. But there is no space or extra lines after the brackets.

Here, the emptystring keyword does it requires a space or Emptyline?

{{if(length(26.org_id.name) > 0; 26.org_id.name + newline; emptystring)}}{{11.Salutation}}{{11.first_name}} {{11.last_name}}

That should be correct then. Can you provide an example output bundle when the 26.org_id.name variable is not available?

2 Likes

Hi,

that solution worked. The issue was with API, its working fine now.

thanks!

1 Like