Setting a hidden Record Producer field's value using dom manipulation in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 11:03 PM
Hello,
I am unable to access the value of a hidden variable field named `captcha` in the record-producer script using producer.captcha, it's showing as empty.
I am setting it's value using javascript in the frontend through this script. :
document.querySelector('input[name=captcha]').value = grecaptcha.getResponse();
This value is set by another widget (custom captcha widget) which renders alongside the record producer.
I have verified that the input value is being set in the frontend, but I don't get it why the value is showing empty in the record producer script.
Any help/suggestions please.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:28 AM
Can you share your complete business requirement?
you cannot set variable value from record producer script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 01:46 AM
@Ankur Bawiskar
My business requirement is that I want to validate a captcha on the server side, for this I would need the captcha response, which is provided by the grecaptcha.getResponse(), where grecaptcha comes from the google recaptcha widget and is available in frontend.
For this, I am trying to use a hidden form field, and send the captcha response along with the form.
I am not setting the value from record producer script, instead from the frontend script of the custom captcha widget:
<div ng-if="!data.logged_in">
<body>
<div class="g-recaptcha" data-sitekey="{{data.sitekey}}" data-callback="setCaptchaResponse" data-expired-callback="setCaptchaResponse"></div>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
function setCaptchaResponse(){
document.querySelector('input[name=captcha]').value = grecaptcha.getResponse();
}
</script>
</body>
</div>
Regards
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 01:52 AM
then do that validation in widget itself
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
