1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Hiding custom field based on User Organization

Discussion in 'Style and design' started by Ryan Devine, Jul 3, 2014.

  1. carlc

    carlc Member

    Thanks for the reply Gurpreet, I'm just getting back to this after some vacation time.

    I created a Group named "Bamco_only" to place fields I only want users from Bamco to see.
    I created an Organization named "Bamco" and assigned it the organizationid = 1

    I placed the recommended code into the Customfield template just below the first line as shown below:

    <{foreach key=key item=_customFieldGroup from=$_customFields}>
    <{if $_user[userorganizationid]==1}>
    <{if $_customFieldGroup[title]=='Bamco_only'}>


    It does correctly show the Bamco_only Custom Field Group for Organization 1 and hide it from all others.

    However, it also hides all of the other Custom Field Groups from all organizations ie. 1,2,3,4,5...

    In rereading your posting above I believe I've omitted the following which is causing the issue:

    Open the template: submitticket_form and replace the line of code:
    HTML:
    <{RenderTemplate name="customfields"}>
    with
    HTML:
    <{if $_user[userorganizationid] ==1}>
    <{RenderTemplate name="customfields"}>
    <{/if}>

    4. Open the template: viewticket and replace the line of codes:
    HTML:
    <{RenderTemplate name="customfields"}>
    <div id="customfieldchangednotice"><em><{$_language[vtcustomfieldchangednotice]}></em></div>
    with
    HTML:
    <{if $_user[userorganizationid]==1}>
    <{RenderTemplate name="customfields"}>
    <div id="customfieldchangednotice"><em><{$_language[vtcustomfieldchangednotice]}></em></div>
    <{/if}>


    Can you please confirm if my understanding is correct?

    Thank you in advance.

    Carl
     
  2. Gary McGrath

    Gary McGrath Staff Member

    Hi Carl,

    If I am reading the above correct, you just need to link your checks together.

    Currently you have:

    <{if $_user[userorganizationid]==1}>
    <{if $_customFieldGroup[title]=='Bamco_only'}>

    This should be:

    <{if $_customFieldGroup[title] != 'Bamco_only' || $_user[userorganizationid] == 1}>

    ( don't forget this will mean you need to remove one of the /if tags from the bottom )

    That should stop it from removing all the customfields from everyone.

    Gary
     
    carlc likes this.
  3. carlc

    carlc Member

    Perfect! Thank you very much.
     
  4. cmonteiro

    cmonteiro Member

    Hi guys,

    Just noticed one weird behavior with this customization.
    When using the default language, it works perfectly. However, if I change the language, the hidden fields are shown anyway.

    Any ideas?
     
  5. cmonteiro

    cmonteiro Member

    Just wondering if anyone got an idea on what to do to fix this.
     
  6. anhlamgame

    anhlamgame New Member

    Yes, we can display only a group of custom fields. I have checked the templates code and I an edit the code to load only a group of custom fields. I need you to explain how you wish to manage them. I will then tweak it accordingly.
     
  7. Jeremiah Cich

    Jeremiah Cich New Member


    I am looking to do something similar except for the registration page for 3 different template groups.
    what i want it to do is this:
    It will check the Template group "name" of the user trying to submit a registration and if the user belongs to "Test" template Group, then it would load the custom fields that belongs to custom field group called 'test'.
     

Share This Page