CB field for js function

7 months 2 weeks ago #335082 by activha
CB field for js function was created by activha
Hello 

I would need your ideas about the following. 

For some of our professional customers we would like to offer them a way to write a personalized js function   

This function would be stored in a CB field and called to be integrated in our node application. 

what kind of field could I use to allow these users to store their js code ?

This code would allow them to write their own tool to be used within our IA application 

thanks for your ideas

Please Log in to join the conversation.

7 months 1 week ago #335091 by krileon
Replied by krileon on topic CB field for js function
That is a major vulnerability waiting to happen and I HIGHLY suggest you do not do this. Regardless yes it's doable.

Create a Textarea field then raw substitute (e.g. [FIELD_NAME]) it into a Code auto action with Method set to JavaScript. It's possible depending on what they put in the field though some of it might get filtered away so you might have to make a new fieldtype plugin for CB that is completely unfiltered.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 months 1 week ago #335104 by activha
Replied by activha on topic CB field for js function
I cannot see how to use an autoaction, the raw field should be retrieved directly from the DB by SQL and written in the node.js code.

The field will be pasted in a function which will only returni a text string but the customer can write what they wish in the field.

The code will be like :
    const companytool1 = new DynamicTool({
          name: "CompanyTool1",
          description: `this tool will be used to : ${user.cb_function_field_description}`,
            func: async (input, runManager) => {
            console.log('USERINPUT', input);  
            ${user.cb_function_field_raw} //output $string
            return $string;
        }  
    }); 

so what I need is a way to (securely if possible) output the cb fields with the js code written by the customer team.

Please Log in to join the conversation.

7 months 1 week ago #335109 by krileon
Replied by krileon on topic CB field for js function
You would substitute it in like you would any field substitution usage. Use [FIELD_NAME] to substitute in the raw database value.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 months 1 week ago #335118 by activha
Replied by activha on topic CB field for js function
OK fine, I'll use isolated-vm with node.js and that should do it :-)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.217 seconds

Facebook Twitter LinkedIn