Service Portal - Dynamic HTML Content

arnabbose
Tera Expert

Hi,

Based on Company of user, below highlighted lines are supposed to appear / disappear on homepage on my SP.

I can use gs.getUser().getCompanyID() in Server Script to publish different results based on Company but how can I make the HTML Texts disappear based on that?

find_real_file.png

8 REPLIES 8

arnabbose
Tera Expert

LaurentChicoine
Tera Guru

Hi Arnab,



In the server script set a data attribute saying if it should be displayed. EX:



var visibleCompanies = ['sys_id1', 'sys_idx'];


if(visibleCompanies.indexOf(gs.getUser().getCompanyID().toString()) > -1){


        data.visible = true;


}


else{


        data.visible = false;


}



Then use the data object inside your HTML template to display or not display a specific HTML tags:



<tag ng-if="data.visible">Content</tag>


I did it via passing the HTML content also into the server data.answer query parts...


Hi Arnab, just got a chance to look at this, but I agree with Laurent. That is the right way to do it. use the ng-if attribute on your center or p1 elements, or you can wrap those 2 sections in another div or p element and add the ng-if to that.