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. Ryan Devine

    Ryan Devine New Member

    I have two user organizations that will be submitting tickets to the same department. But one of those organizations I need to have them provide additional information that the other department doesnt. I dont want the second organization to know the custom field exists.

    How do I edit the customfield template to restrict this?
     
  2. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Ryan,

    I have a solution with me and I can share it with you. However, there is a little flaw. If there are Mandatory custom fields, it would not allow creation of ticket.

    Let me know shall I share the solution with you!
     
    bibomartcpn likes this.
  3. Ryan Devine

    Ryan Devine New Member

  4. Ryan Devine

    Ryan Devine New Member

    Your solution, does it allow me to hide it from the user but be able to edit it from the ticket?
     
  5. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hello Ryan,

    Yes, with my solution, the fields would not be available to the end users. Staff can surely view and update/edit the field values.

    Solution is:

    1. Locate the User organization Id of the concerned organization whom you wish to display the fields. You can get the organization from: Staff Interface > Users > Manage Organization > Click on the Organization title, and then check the URL in the address bar. It should be like: http://localhost/66/staff/index.php?/Base/UserOrganization/Edit/1, here 1 at the end of the URL is the organization ID.

    2. Now you have the Organization ID with you, you can now edit the templates named: submitticket_form and viewticket. You can find these templates under: Admin Interface > Options > Templates > Groups > Edit a group > Templates > Tickets

    3. 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}>
    Once this done, the custom fields will only be visible to users of the organization having Organization ID 1.

    Hope it helps!
     
  6. Ryan Devine

    Ryan Devine New Member

    Is this applied to all custom fields or just the ones that I want?
     
  7. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hello Ryan,

    This will work for all the custom displayed while creating and updating tickets. In other words, it will be for all the ticket related custom fields.
     
  8. cmonteiro

    cmonteiro Member

    Hi Gurpreet,

    Is there any way we could use this to display, let's say, only a group of customfields?
     
  9. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Cmonteiro,

    I haven't checked that yet. I will check and update you soon.
     
  10. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Cmonteiro,

    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.
     
  11. cmonteiro

    cmonteiro Member

    That's great Gurpreet!
    What I need is to load a group of custom fields to a particular group of users only.
    All the others cannot view it.
     
  12. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Cmonteiro,

    Thank you for explaining your requirements. Please try the following code segment.

    1. Open template 'customfields'. After first line, add the following lines of code:
    HTML:
    <{if $_user[usergroupid]==2}>
                           <{if $_customFieldGroup[title]=='Test'}>
    2. In the same template, before last line, add the following lines of code:
    HTML:
        <{/if}>
    <{/if}>
    Let me explain, what this code is supposed to do. It will check the user group ID of the user trying to submit a ticket and if the user belongs to 2nd User Group, then it would load the custom fields that belongs to custom field group called 'Test'.

    Hope it helps!
     
  13. cmonteiro

    cmonteiro Member

    Hi again Gurpreet,

    I'm sorry for taking this long to get back to you at this.
    I've followed the instructions you gave me and it did not work as expected.
    I've included the if condition right after the foreach line and it the group I've tested was gone for all user organizations, including the one in the condition it was supposed to be shown.

    Any idea on why this might have occurred?
     
  14. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Cmonteiro,

    The code was developed according to user groups conditions as mentioned in your in request (What I need is to load a group of custom fields to a particular group of users only.). If you wish to display it per user organization, then you need the condition:

    <{if $_user[userorganizationid]==1}> instead of <{if $_user[usergroupid]==2}>

    Please try this and share your findings.
     
  15. cmonteiro

    cmonteiro Member

    It worked Gurpreet! Thanks for the help! This will be very helpful.
     
  16. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Cmonteiro,

    Glad to know that I was able to help you out.

    Have a nice day!
     
  17. carlc

    carlc Member

    I have a similar requirement:
    One of our custom fields is a dropdown of customer names. This is used for internal purposes.

    We'd like to now open up the ticketing system to our customers but we do not want them to be able to see our list of customers but I still need our own staff to identify the customer. So I either need to hide the field from the customers or ideally populate it based on their Organization with no ability to edit or view the other options.

    I have removed the "Create a ticket" widget from the home page for the time being.

    Any assistance would be appreciated.
     
  18. carlc

    carlc Member

    I was trying to follow the logic of the above - I created a new Custom Field Group called "Test" and placed the fields I wanted hidden from customers into this Group.

    Our organization = 1, so I used:

    <{if $_user[usergroupid]==1}>
    <{if $_customFieldGroup[title]=='Test'}>

    <{/if}>
    <{/if}>

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

    However, it also hide all of the other Custom Field Groups from all organizations ie. 1,2,3,4,5... I must be missing something to include all other Custom Field Groups.
     
  19. Gurpreet Singh

    Gurpreet Singh Staff Member

    Hi Carlc,

    I have two suggestions for you.

    • Why do not you try inserting Custom Fields of type Staff Ticket Creation, they would not be available to the end users and only your Staff would be able to see and edit them.
    • In your logic you are using <{if $_user[usergroupid]==1}>, this checks if the user group of the user is 1, however, you are developing the logic for user organization. Try using <{if $_user[userorganizationid]==1}>
    Hope it helps!
     
  20. bibomartcpn

    bibomartcpn New Member

    Hi Gurpreet,
    Thank you, You showed me your answer
     

Share This Page