Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2019-01-04 03:13 PM
We are working on a requirement wherein we have two manual record permission fields that get populated at different stages of a workflow, the idea is to not have the same person in both these record permission for which the following custom object was written
<script type="text/javascript">var reviewerFieldId = 1234;var peerreviewerFieldId = 5678;Sys.Application.add_load(function() {$('div[id*="f' + peerreviewerFieldId + 'cdp"]').change(function(){var rev1 = $CM.getFieldValue(reviewerFieldId);var rev2 = $CM.getFieldValue(peerreviewerFieldId);if(rev1=rev2){alert('Peer reviewer and Reviewer cannot be same person');});});
</script>
Alert is followed by clearing the name from second record permission field, however we are unable to trigger the .change event for this most probably it could be due not have proper element selected.
Kindly advise if record permission fields have different Jquery selector compared to other general fields.
We have tried the following selectors
1.$('div[id*="f' + peerreviewerFieldId + 'cdp"]')
2. $('input[id*="f' + peerreviewerFieldId + 'shf"]')
3.$('div[id*="f' + peerreviewerFieldId + 'c_s"]')
None of them worked
Archer version is 6.4 HF1.
2019-01-05 08:13 AM
I had some time on Saturday to think a bit deeper into the case, and came up with one very nasty approach to resolve the main issue, but one should never use it for obvious reasons. Still, if you understand implications, you may use for your own risk and sake:
<script>
Sys.Application.add_load(function() {
redefineStandardSetter($("#master_DefaultContent_rts_s566_f17143c_shf")[0], "value");
$("#master_DefaultContent_rts_s566_f17143c_shf").change(function(){
// Do perform here the onchange actions
});
});
function redefineStandardSetter(obj, property) {
Object.defineProperty(obj, property, {
configurable: true,
enumerable: true,
set: function(value) {
this.setAttribute(property, value );
$("#master_DefaultContent_rts_s566_f17143c_shf").trigger('change');
},
get: function() {
return this.getAttribute(property);
}
});
}
</script>
1. Change input identifiers to your own.
2. I was lazy enough to not make function for retrieving the input identifiers for better coding, so excuse me for scrappy code.
3. I tried it on the ValuesPopup type of a RP fields. Dunno if it would work on the Dropdown, etc.
2019-01-04 03:36 PM
I think your #2 might have a typo...
'c_shf"]'
2019-01-04 03:49 PM
2019-01-04 03:51 PM
Majority of Archer fields, the values are stored in hidden input elements which the change event cannot be fired.
You can see if detecting a change on the parent div element like so:
$('div[id$="f' + peerreviewerFieldId + 'c_s"]').change(function(){
//Field Changed
]);
Also looking at the screenshot of the code. I don't think you have the proper closing curly brackets in the right place. Indentation goes a long way in helping what curly bracket closes what
Advisory Consultant
2019-01-04 03:52 PM
However, I feel like there's an issue trying to attach a change event to the field.
I was looking for the thread and I think Ilya Khen just posted it.
I believe I've addressed this in 2 different ways.
1. setInterval - Makes it appear as though it's off of a change event
2. Save button
2019-01-04 04:01 PM
I find pretty ridiculous, how I cannot mark in SOME topics answers (for example Jason's and David's in this case) to be useful. No AD blocker, different browser, no FW, AV turned off, but after reload - useful answer marked by me gets disappeared.
But if I mark answer as NOT useful, that answer is saved, lol. Sorry, David, if your answer is indicated as not useful because of my testing I cannot do anything about it now
And that happens pretty random. Anyone met his?
2019-01-04 04:01 PM
Thanks Ilya Khen I was looking for these links... I know we recently had discussions about it.
I think I recall finding that mutation observer didn't work in IE 11 for me.
2019-01-04 04:04 PM
Also, rev1 = rev2 should probably be rev1 == rev2
Otherwise you're setting rev1 to rev2.
2019-01-04 04:05 PM
Yeah, I was also looking for that discussion We discussed Event handlers here https://community.rsa.com/message/921764?commentID=921764#comment-921764
2019-01-05 05:08 AM
Hi Jason/Ilya/David,
New year greetings and thank you for sharing your responses, unfortunately the Jquery selector did not work for me
$('div[id$="f' + peerreviewerFieldId + 'c_s"]')
I corrected the missing closing curly bracket .
Also while trying to troubleshoot this I had kept the the inspect element viewer open and noticed that only values are getting updated in the hidden input fields and should have been captured by the parent div ... when I try to specifically check on hidden input element it still does not work .