Custom Javascript in custom app not working as expected

Dear community,

I am building a custom Make App SeaTable and want to use Javascript in my custom app to remove a substring from a string - or o be concrete I want to use the build in IML functions replace(). (JavaScript in Make - Make Apps).

In the list of supported functions, you can find the following.

Function Specification
replace() Replaces the search string with the new string.

Unfortunately, it is not explained how to use, but I assume it can be used like this - because this is the way how it is used in the module editor (browser).

"qs": {
  "path": "{{replace(parameters.table;search;replace)}}"
}

This is working like a charm but only with static strings for search and replace. As soon as I want to use a variable in the search, it is not working anymore. I tried almost everything: single variable, variable with ', variable with escaped ', … Non of these approaches work.

replace(parameters.table;parameters.url;'/')
replace(parameters.table;'string'+parameters.url+'/...';'/')
=> not working!

Question

Can anybody tell me how to use replace with variables? Do I really have to write a custom IML function to do such an easy task like replacing/removing a substring?

Best regards
Christoph

Hey @Christoph_Dyllick-Br

You should try this

“qs”: {
“path”: “{{replace(parameters.table; ‘{{search}}’; ‘{{replace}}’)}}”
}

OR

“qs”: {
“search”: “string”,
“replace”: “newString”,
“path”: “{{replace(parameters.table; parameters.search; parameters.replace)}}”
}

2 Likes

Attempt 1:

"qs": {
        "search": "https://",
        "replace": "test",
        "path": "{{replace(parameters.assetPath; parameters.search; parameters.replace)}}"
},

That does not work, as you can see in this picture.

Where did you find that in the documentation:

Attempt 2:

"qs": {
      "path": "{{replace(parameters.assetPath; {{connection.serverURL}}; 'test')}}"
},

does not work either.

image

Attempt 3:

"qs": {
      "path": "{{replace(parameters.assetPath; connection.serverURL; 'test')}}"
},

This works. I don’t know why, but in the end, I achieved, what I want to get with

"path": "{{replace(parameters.assetPath; connection.socketUrl+'workspace/'+connection.workspaceId+'/asset/'+connection.dataTableUuid+'/'; '/')}}"

I assume that I made the mistake, that the replace value can not be just empty with ''. Therefore I added '/'.

Thanks for your help.

1 Like

Hello there @Christoph_Dyllick-Br :wave:

I just want to quickly step in and say awesome work getting this up and running with the help of @Abhishek :clap:

Thanks a lot for circling back here and sharing your progress as well as the final setup with us. This is incredibly valuable and has the potential to help many others searching for similar info down the road :pray:

1 Like