Results 1 to 5 of 5

Thread: Assigning default values in record creation

  1. #1
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    426

    Default Assigning default values in record creation

    Hi all

    I have a custom field for Contacts module that it is mandatory and it is a dropdown of a list of values.

    I know I can set up a default value, but what I would like to do is to pick this default value depending on the assigned user's deparment. I mean I would like, some how, the system to read the department of the assigned user and depending on its value, assign a value to this mandatory dropdown field.

    I have tried to get this with logic hooks, using the after_retrieve, but in the manual says that this hook does not fire when you create a new record, and it is during the record creation when this functionality is useful.

    Is there any other way to perform this action when a new Contact record is created?

    I have the code ready and working in the before_save or after_save logic hooks, but this is not right for me as I need the user to "see" the value in the field before submiting the record using the "save" button. The default value is a suggestion, but has to be confirmed or changed by the user before saving it.

    Thanks a lot in advance

  2. #2
    SagarCRM's Avatar
    SagarCRM is offline Sugar Community Member
    Join Date
    Oct 2011
    Location
    Mumbai, Maharashtra, India
    Posts
    111

    Default Re: Assigning default values in record creation

    Quote Originally Posted by jlabuelo View Post
    Hi all

    I have a custom field for Contacts module that it is mandatory and it is a dropdown of a list of values.

    I know I can set up a default value, but what I would like to do is to pick this default value depending on the assigned user's deparment. I mean I would like, some how, the system to read the department of the assigned user and depending on its value, assign a value to this mandatory dropdown field.
    Hi jlabuelo,

    you can fetch department of current user on load of view.edit.php

    and set department value whatever you want


    PHP Code:

    global $current_user
        
    if(
    $current_user->department == 'sugarcrm')
    {
         
    $this->bean->designation_dropdown_c 'developer';

    --

    Thanks & Regards,

    Sagar Salunkhe
    Mumbai, Maharashtra, INDIA

    sagar.salunkhe1991@gmail.com

    ~~ IT professionals never dies, they just go Offline... ~~


    sugar development and support services:- indian.sugarbean@gmail.com

  3. #3
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    426

    Default Re: Assigning default values in record creation

    Hey

    Thanks a lot for the help, works like a charm!!

    Regards

  4. #4
    ivit is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    187

    Default Re: Assigning default values in record creation

    Pay attention that proposed code will work only if current user does not change assigned user field (current user) before saving.

    In case you want to change dropdown value when assigned user is changed, you will need to write JavaScript to accomplish that.

  5. #5
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    426

    Default Re: Assigning default values in record creation

    no thanks, I just need this when an user creates a record, and I use the "creator" user not the user that it is being assigned in the "Assigned to" field.

    Thanks for the advise!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 2011-07-20, 06:27 AM
  2. Replies: 3
    Last Post: 2011-04-19, 03:53 PM
  3. Replies: 3
    Last Post: 2010-06-01, 02:55 PM
  4. Disable Record Creation for a Role?
    By pwieland in forum Help
    Replies: 3
    Last Post: 2009-05-18, 09:46 PM
  5. Simple 1 to many record/table creation
    By restorick in forum Help
    Replies: 3
    Last Post: 2009-03-13, 02:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •