Need to populate all fields in single field type HTML line by line when insert or update record

Brahmi Pandla
Tera Guru

Hi

 

I have requirement   populate all fields data into single field type HTML when the record insert or update

 

For example I have category, subcategory, description fields  and need populate all fields into  artilcle body(html type) field like below shown

 

Category : Hardware

subcategory: CPU

Description: This is hardware issue

 

 

3 ACCEPTED SOLUTIONS

Peter Bodelier
Giga Sage

Hi @Brahmi Pandla,

 

You could use something like this, depending on where you where planning of using it of course:

 

var body = '';

body += '<p>Category: ' + current.getDisplayValue('category') + '</p>';
body += '<p>Subcategory: ' + current.getDisplayValue('subcategory') + '</p>';
body += '<p>Description: ' + current.getDisplayValue('description') + '</p>';

current.body = body;

 

 

Edit: Adjusted to show the right answer.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

Hi @Brahmi Pandla,

 

Just tested it. Seems that </br> get removed.

It works like this:

var body = '';

body += '<p>Category: ' + current.getDisplayValue('category') + '</p>';
body += '<p>Subcategory: ' + current.getDisplayValue('subcategory') + '</p>';
body += '<p>Description: ' + current.getDisplayValue('description') + '</p>';

current.body = body;

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

Hi @Brahmi Pandla,

 

Did you try the last script I provided?

It's working as expected for me.

var body = '';
if (current.getDisplayValue('category')){
body += '<p>Category: ' + current.getDisplayValue('category') + '</p>';
}
if (current.getDisplayValue('subcategory')){
body += '<p>Subcategory: ' + current.getDisplayValue('subcategory') + '</p>';
}
if (current.getDisplayValue('description')){
body += '<p>Description: ' + current.getDisplayValue('description') + '</p>';
}

current.body = body;

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

15 REPLIES 15

Hello Peter,

 

Could you please help on above query  Thanks

Hi @Brahmi Pandla,

 

Did you try the last script I provided?

It's working as expected for me.

var body = '';
if (current.getDisplayValue('category')){
body += '<p>Category: ' + current.getDisplayValue('category') + '</p>';
}
if (current.getDisplayValue('subcategory')){
body += '<p>Subcategory: ' + current.getDisplayValue('subcategory') + '</p>';
}
if (current.getDisplayValue('description')){
body += '<p>Description: ' + current.getDisplayValue('description') + '</p>';
}

current.body = body;

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Yes Peter I tried same script  getting like below

 

Category: Hardware

Subcategory:

Description: This is hardware issue

 

 

Hello peter

 

The below is used script

(function executeRule(current, previous /*null when async*/ ) {
    var body = '';
    body += '<p>Regulators and Enforcement Priorities: ' + current.getDisplayValue('reg_en_prior') + '</p>';
    body += '<p>Key data privacy laws and regulations: ' + current.getDisplayValue('kd_prilaw_reg') + '</p>';
body += '<p>Territorial Scope: '  +current.getDisplayValue('territorial_scope') + '</p>';
    current.article_body = body;
    current.update();
 
})(current, previous);

Ah, but that is very different from what I provided...

 

(function executeRule(current, previous /*null when async*/ ) {
    var body = '';
if(current.getDisplayValue('reg_en_prior')){
    body += '<p>Regulators and Enforcement Priorities: ' + current.getDisplayValue('reg_en_prior') + '</p>';
}
if(current.getDisplayValue('kd_prilaw_reg')){
    body += '<p>Key data privacy laws and regulations: ' + current.getDisplayValue('kd_prilaw_reg') + '</p>';
}
if(current.getDisplayValue('territorial_scope')){
body += '<p>Territorial Scope: '  +current.getDisplayValue('territorial_scope') + '</p>';
}
    current.article_body = body;
    current.update();
 
})(current, previous);

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.