0

I have custom fields underneath a relationship type that I want to restrict to view only or entirely remove if they are not a specific user. I can make the permissions work so the issue is load order I think. My jQuery code in Relationship.extra.tpl loads before the custom fields appear. I suppose my answer lies somewhere here https://docs.civicrm.org/dev/en/latest/framework/ajax/ but any pointers to get me in the right direction?

2

You can use preProcess or BuildForm hook on formname CustomDataType and unset the custom group or field based on user role or id

You can use PageRun hook and unset the variable in smarty template based on condition and it will not display on view page

since the custom fields are build using ajax, you can also use ajaxSuccess jq event to remove the custom field using Relationship.extra.tpl

|improve this answer|||||
  • Can this be done in an extra.tpl file? – Andy Burns Mar 24 at 0:40
  • 1
    Try customdatatype.tpl but this file is invoked on all entity – Pradeep Nayak Mar 24 at 1:47
1

Putting this in Relationship.extra.tpl works. Both ajaxSuccess or ajaxComplete events works. Thank you Pradeep.

{literal}
<script>
CRM.$( function( $ ) {
    $( document ).ajaxSuccess(function( event, request, settings ) {
     // do stuff
    } )
 } )
</script>
{/literal}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.