Forum Discussion

Jack_Machesky's avatar
Jack_Machesky
Cloud Apps
02-21-2024
Solved

Customizing Widget Return Text

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!

 

9 Replies

Replies have been turned off for this discussion
  • 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?
    • Jack_Machesky's avatar
      Jack_Machesky
      Cloud Apps

      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

  • 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.