0

In my salesforce app, there is an aura:component which contains a Html Page Builder. I use Bee Plugin to do that. When the user designs the page and clicks the Save button, Bee plugin will generate html and json code of that page. I will save those two in a custom field in a custom object, so that I can load the json code each time when the user opens this component. Everything works fine. The only problem I have is that I want a particular template to be opened when the user opens the app for the first time. My plan was to set the json code as default value for the field that saves the json code. Lets call that field JsonCode__c. So, basically I want to set a 1000 lines of json code as default value for the field JsonCode__c. But, when I go to the salesforce Setup -> Object Manager, and tried to paste the code to the default value text area of the field, only few lines of the code is getting pasted. So, how can I do that? How to add a very big string as a default value of a custom field? The data type of JsonCode__c is Long Text Area.

1

Custom text fields only support 255 characters. You can try using a rich text area or long text area, but you'll have to use Apex to populate the field before the record is created (i.e as a default value).

In particular, you'll need to use a Before Insert Trigger.

| improve this answer | |
  • i am using long text area. i think the problem is not with length because insertion works fine for 1000 lines of code. setting default value is the problem – Jayesh Babu May 29 at 13:16
  • @JayeshBabu When you set a default value, you're technically setting up a formula. It's possible your JSON exceeds the 4KB max size allowed for formulas, though I would hope Salesforce would have an error for that scenario. – nbrown May 29 at 13:26
1

You can set the default template value in the lighting component itself. When the user loads the record using your component and there is no data in that field just put the default value in the field. Also, you can put that value if it's a new record.

To be able to change the default template, without changing the code. Use the static resource to store it and load the resource in the component, so the admin can change the template whenever needed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.