Default Text in a field

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi there - I'm trying to default a text for a field. Scenario is that I have a button that is opening a popup to enter notes. I want to default the comments, subject, etc. I have 4 "notes" buttons, but each of the 4 buttons will have different default text. So, button 1 subject says button 1, button 2 subject says button 2, and so forth. I'm trying to not have to create 4 different models with all the same functionality with exception of the default text. Does anyone have away around this without any JavaScript?
Photo of Ryan Faust

Ryan Faust

  • 884 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Have your button run multiple actions:
1) create a new row
once you have selected this action, you will see a little plus sign on the action. Click it. It will allow you to pre populate fields with certain values
2) open pop up
Photo of Ryan Faust

Ryan Faust

  • 884 Points 500 badge 2x thumb
Thank you! I knew that was somewhere but I just couldn't find it. One more question - in my default text, I want to have it show on 2 different lines (I want to enter a page break). Have you done this before?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
The field would have to be a text area or rich text. Still, I'm not sure this would work. What you probably want is to have one field represent your first line and a second field represent your second line. Then display both fields together in a template field. The template field can be laid out however you want and merges in the values from the regular salesforce fields.
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
I did a page break (in a text area) ...never could get it to work in the declarative actions, and ended up doing it in a snippet.  This was just used in a demo and I never fully tested it in a bunch of browser versions.  But essentially the comment string became:

newComment = commentLine1 + '/n' + commentLine2;

and the /n produced a carriage return.

So you could run a snippet before showing your pop up that added the break, something like this: (replace CommentModel and Comments__c with your actual model and field)

var params = arguments[0],$ = skuid.$;
   
var myModel = skuid.model.getModel('CommentModel');

var myRow = myModel.getFirstRow();

var commentLine1 = "First Line of Comments";
var commentLine2 = "Second Line of Comments";

myComments = commentLine1 +  '\n' + commentLine2;
                
myModel.updateRow(myRow,{Comments__c: myComments});