Created
October 9, 2023 00:00
-
-
Save jon-dixon/4a86095e46aef310091e096e2bcfa395 to your computer and use it in GitHub Desktop.
JS Function to Detect Clicked Help Source and Call Server Process to get Help Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @namespace var cnHelpUtil = {}; | |
**/ | |
var cnHelpUtil = {}; | |
/** | |
* @function showHelp | |
* @example cnHelpUtil.showHelp(this, 'ITEM'); | |
**/ | |
cnHelpUtil.showHelp = function (theEvent, helpTrigger) { | |
// Stop the standard help functionality from running. | |
theEvent.browserEvent.stopImmediatePropagation(); | |
let helpValue; | |
// Determine if trigger was a Page Item or an IG/IR Column. | |
if (helpTrigger == 'ITEM') { | |
helpValue = $(theEvent.triggeringElement).attr('data-itemhelp'); | |
} else { | |
helpValue = $(theEvent.triggeringElement).attr('cn-help-key'); | |
} | |
apex.debug.info("Trigger ", helpTrigger); | |
apex.debug.info("Source ", helpValue); | |
// Call Server Process to Fetch the Help Text. | |
apex.server.process('FETCH_CUSTOM_HELP', | |
{x01: helpTrigger, | |
x02: helpValue}, | |
{success: function (pData) { | |
// Display the Help Text. | |
apex.theme.popupFieldHelp({title:'Item Help', helpText: pData.help_text}); | |
}, | |
error: function(e){ | |
console.log(e); | |
apex.message.clearErrors(); | |
apex.message.showErrors([ | |
{ | |
type: "error", | |
location: "page", | |
message: 'Unable to get get Custom Help', | |
unsafe: false | |
} | |
]); | |
}, | |
dataType: "json" | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment