cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing Widget Return Text

Jack_Machesky
9 - Travel Pro
9 - Travel Pro

I was wondering if it was at all possible to customize what a widget that is based off of a salesforce field returns. What the widget points at returns a value of either "True" or "False", but I would like it to return "Yes" or "No" instead. Is this possible? Thanks!

 

1 ACCEPTED SOLUTION

Hi @Jack_Machesky ,

I don't think this will work straight OOTB - you'll need to edit the script to meet your requirement.

Firstly, you'll need to add the title of the item you'd like to manipulate into the panelTitlesToAffect array at the start of the script. i.e. your salesforce field name (s).

Secondly, you'll need to change the rules starting from if (cell.Value === 'x') { cell.Text = 'y' } to change the 'x' value from the exact value that you want to change (so if 'true' with no capitals, it needs to be 'true', etc.) to the value you'd like to display in it's place - 'y'.

I'm happy to provide a consult if you'd like to look more deeply or have any issues implementing:

Sisense Services | Free 30-Minute Sisense Consultation (rapidbi.com.au)

Let me know how you go?

View solution in original post

9 REPLIES 9

DRay
Community Team Member
Community Team Member

Hello @Jack_Machesky,

If you are comfortable with a bit of JavaScript you should be able to use the Pivot 2.0 API to do this. Here is the documentation on it. https://sisense.dev/guides/customJs/jsApiRef/widgetClass/pivot2.html

If that's not something you're comfortable with please let us know and we can continue to help.

 

David Raynor (DRay)

I am comfortable with some basic JS, but from my understanding this article is pointing to a pivot table widget, and I am trying to manipulate a Blox widget. Will this method provided in the documentation still work?

DRay
Community Team Member
Community Team Member

I can't confirm without testing it, but I believe it should, although you would need to modify it for working in Blox.

I also found this post from one of our partners that looks very similar to what you trying to do. https://www.rapidbi.com.au/members/index.php?/Knowledgebase/Article/View/sisense-blox---replacing-no...

David Raynor (DRay)

Thanks for the callout @DRay !

I've provided a more in depth, related solution above to update the dated solution provided in the knowledgebase article linked.

Solution here will manipulate the result prior to render rather than 'change the result after its been rendered'. It should be more flexible, more performant and less noticable to the viewer.

rapidbisupport
10 - ETL
10 - ETL

Hi @Jack_Machesky ,

This will depend on the widget type.

For a BloX Control, i'd work on changing the result prior to rendering the widget in the processresult event.

const panelTitlesToAffect = ['Region', 'panel2']

widget.on('processresult', (w, args) => {
	// args.result looks like:
	// [{
	// { panel: 'panel1Title', value: 'panel1value11'}, 
	// { panel: 'panel2Title', value: 'panel2value1'}, 
	// ...}]
	const l = args.result.length

	// for each row in the returned data
	for (let i = 0; i < l; i++) {
		let row = args.result[i]

		// for each cell in the returned data
		for (const key in row) {
			let cell = row[key]

			// if the cell panel is one of the titles defined in panelTitlesToAffect 
			// then do something (in this case, check the cell Value and change the text)
			if (!panelTitlesToAffect.includes(cell.Panel)) { continue }
			if (cell.Value === 'True') {
				cell.Text = 'Yes'
			}
			if (cell.Value === 'False') {
				cell.Text = 'No'
			}
		}
	}
})

The code above establishes firstly the 'Panel Titles to target', and then manipulates the args.result data for the panels specified.

The logic you'll be able to change based on what result you'd like to see, but overall the above will change values of True and False from Panels Region and panel2 to display as Yes and No.

Let me know how you go?

Should I be able to implement this script into my widget without any changes and see the widget correctly reflect "yes" or "no" for "true" or "false"? I have deployed the script and am not seeing any changes.

Thanks,

Jack

Hi @Jack_Machesky ,

I don't think this will work straight OOTB - you'll need to edit the script to meet your requirement.

Firstly, you'll need to add the title of the item you'd like to manipulate into the panelTitlesToAffect array at the start of the script. i.e. your salesforce field name (s).

Secondly, you'll need to change the rules starting from if (cell.Value === 'x') { cell.Text = 'y' } to change the 'x' value from the exact value that you want to change (so if 'true' with no capitals, it needs to be 'true', etc.) to the value you'd like to display in it's place - 'y'.

I'm happy to provide a consult if you'd like to look more deeply or have any issues implementing:

Sisense Services | Free 30-Minute Sisense Consultation (rapidbi.com.au)

Let me know how you go?

Thanks for the chat this morning @Jack_Machesky ! Was great to catch up to talk through.

As discussed - the titles of the relevant panel items should be included in the 'panelTitlesToAffect' array, otherwise they are ignored.

Please don't hesitate to reach out in the future if we can help!

Thanks,

Daniel

RAPID BI

[email protected]

RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

DRay
Community Team Member
Community Team Member

Hello @Jack_Machesky ,

I wanted to follow up to see if the solution offered by @rapidbisupport worked for you

If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)