Values from multi row variable set not populating in knowledge article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 07:57 PM
Hi All,
I have a requirement where I need to create a Knowledge article when a form is submitted from a record producer on the portal. I have used a Multi-Row variable set in that record producer so that users can add multiple rows and information as per their need. I want to populate those rows filled by a user in a Knowledge article. I have created a flow which will create a knowledge article once it is approved. To populate record producer values in the knowledge article, I have written an after update Business rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2023 10:07 PM
Hi @Amol Pawar
The MRVS is stored value as an Array [Object].
So to get the value in the MRVS, just parse it and loop through each element. Sample below.
So in your case, it will be:
1. Get Value of the MRVS sections.
2. Use JSON.parse to parse the variable.
3. Loop through the array to get value of section_name_new, information_section_name_new, etc.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 03:03 AM
Hi @Tai Vu,
Thank you for your reply but even after referring to your solution, I'm unable to populate MVRS values in the knowledge Article.
Anything we're missing?
Amol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 08:20 PM
Hi @Tai Vu,
Thank you for your response, it worked with a few modifications. We can populate data from multi row variable set now, but it's populating as a text format. Can we make it like populate in a table format?
I'm giving BR script for reference:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 10:32 PM
Hi @Amol Pawar
As far as I understand from your scenario is that the section_name_new and information_section_name_new variables are string text (single line text or multiple line text type).
So if you would like to populate into the Article body field with HTML type, you've to add HTML tags beside actual text value.
You can leverage the Template [sys_template] to pre-define a HTML template for the article body. Something like below
Use this API to apply it
applyTemplate(String template)
Then replace the variable ${section_name_new} and ${information_section_name_new} with your own variable's value.
Sample:
var rec1 = new GlideRecord("kb_knowledge");
rec1.initialize();
rec1.applyTemplate("MVRS Template");
rec1.text = rec1.text.replaceAll('${section_name_new}', 'My new name section');
rec1.insert();
Btw, why don't you just use the Script box right inside the Record Producer?
Cheers,
Tai Vu