Widget replace part of a string Knowledge Article Content widget

Eli7
Tera Expert

 

 

Hi All,

We added u_knowledge_owner field to KB articles and its a reference field which retrieves full name and users email address. We are displaying this on the KB articles but I need to change the email address to say Knowledge Owner.

 

KB00XXXXX
Test - Application - SharePoint Test
17d ago17 days ago • 6 Views • Test User (test.user@test-company.com)
SharePoint Test

 

Should look like the below:

KB00XXXXX
Test - Application - SharePoint Test
17d ago17 days ago • 6 Views • Test User (Knowledge Owner)
SharePoint Test

 

How could this be achieved ? Maybe someone has done something similar and could share the code.

 

Many Thanks! 

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hey @Eli7 

From where you retrieve this value "Test User (test.user@test-company.com)", why don't you return the value as you'd like to? Then just binding that variable to the HTML tag.

Sample.

gr.getDisplayValue('u_knowledge_owner').replace(gr.u_knowledge_owner.email, gr.u_knowledge_owner.getLabel());

Screenshot 2023-11-20 at 13.49.03.png

 

Cheers,

Tai Vu

View solution in original post

4 REPLIES 4

Mayur2109
Kilo Sage
Kilo Sage

Hi @Eli7 ,

 

Within widget in the HTML you need to replace the variable, the current variable is fetching the email id in that place replace it with variable which will contain user id. You can fetch the user id for the respective knowledge article from server script.

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,
Mayur Shardul

Hi Mayr,

 

Thank you for your response but I added the user in the HTML to display  • Test User (test.user@test-company.com)  and the value is from the u_knowledge_owner field which I added to the server script. On the KB article its a reference field to user table with attributes: ref_ac_column=name;email and I cannot change that.

I was hoping it could be solved with manipulating the value ie. replace anything within the braces so it would show  (Knowledge Owner) instead of email address. 

 

Hi @Eli7 ,

 

Field  attribute should not affect this on portal side. Can you share that line of code for HTML & Server script if possible, it will help to understand more.

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,
Mayur Shardul

Tai Vu
Kilo Patron
Kilo Patron

Hey @Eli7 

From where you retrieve this value "Test User (test.user@test-company.com)", why don't you return the value as you'd like to? Then just binding that variable to the HTML tag.

Sample.

gr.getDisplayValue('u_knowledge_owner').replace(gr.u_knowledge_owner.email, gr.u_knowledge_owner.getLabel());

Screenshot 2023-11-20 at 13.49.03.png

 

Cheers,

Tai Vu