How to hide Price and total field on Order status screen based on user role

Bhargava4
Mega Expert

Hi Gurus,

if you have  admin role your able to see price and total field order screen in both areas like SN and Service Portal, if not we need to hide those two fields. please post your thoughts 

Maintain cart layout not for this requirement because we need to dynamical based longed user role 

find_real_file.png

1 ACCEPTED SOLUTION

Brent Sutton
Mega Sage

Hi Bhargava,

You would probably have to clone the OOB "SC Order Status" widget to do what you are describing. I would question the value of running your own widget rather than just configuring the widget instance to hide the price and total cost.

CTRL-Right Click "SC Order Status" widget >> Select "Instance Options"

find_real_file.png

Deselect "Display Price" and "Display Total Price"

find_real_file.png

Result:

find_real_file.png

This would hide the "Display Price" and "Display Total Price" fields for everyone (including admins) but would be much more supportable long term.

Let me know if this worked for you.

Brent

View solution in original post

9 REPLIES 9

puneetgoels1
Tera Guru

you may need to modify ui macro servicecatalog_cart_template

Brent Sutton
Mega Sage

Hi Bhargava,

You would probably have to clone the OOB "SC Order Status" widget to do what you are describing. I would question the value of running your own widget rather than just configuring the widget instance to hide the price and total cost.

CTRL-Right Click "SC Order Status" widget >> Select "Instance Options"

find_real_file.png

Deselect "Display Price" and "Display Total Price"

find_real_file.png

Result:

find_real_file.png

This would hide the "Display Price" and "Display Total Price" fields for everyone (including admins) but would be much more supportable long term.

Let me know if this worked for you.

Brent

Hi Brent,

 

Thank you for your swift response. There is any possibility to restrict based on roles.

 

Thanks,

Ram chekuri

Hi Ram,

Unfortunately not, the widget instance options will apply to everyone (including admins). That's why I was saying that you would have to clone the OOB "SC Order Status" widget and amend to build the logic to only show price and total to admins.

I personally wouldn't go down this route as you will then be responsible for maintaining the widget from then on.

If you did want to clone the widget then you could add the following to the server side script:

data.isAdmin = gs.hasRole("admin");

and on HTML template side you would have to amend the ng-if statements that determine which fields are displayed. I only have a Madrid developer instance so I can tell you which lines to amend on this:

<!–– Line 55 html template for SC Order Status widget in Madrid -->
<th class="wrapper-md col-md-2 hidden-sm hidden-xs" ng-if="(::options.display_price === 'true' && data.showPrices) || data.isAdmin">${Price} (${ea.})</th>


<!–– Line 57 html template for SC Order Status widget in Madrid -->
<th class="wrapper-md col-md-2" ng-if="(::options.display_total_price === 'true' && data.showPrices) || data.isAdmin">${Total}</th>

screenshot below:

find_real_file.png

Hope this helps

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.