Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: automatic creation of a field

  1. #1
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Red face automatic creation of a field

    Hello again friends...

    • I'm in the edit view of my custom module (created by the builder module) called illumination


    1. This module, among other fields, have a field 'client' of kynd relationship, with the module called clients
    2. This module will contain many records
    3. My intention is that each time you save a record, automatically create a field 'numbers', in the format: clientname_ILUx, where 'x' is a counter


    For example:

    First record -> clientname_ILU1
    Second record-> clientname_ILU2
    N record-> clientname_ILUN

    What are the steps? I hope your answers
    Thank you very much!

  2. #2
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: automatic creation of a field

    I do not know exactly for what propose it is needed, but you can dinamically create fields computing a new file under /custom/Extation/modules/Custom_module/Ext/Vardefs/new_file_name.php
    This file has to have a content like:
    PHP Code:
    <?php 
    $dictionary
    ["custom_module"]["fields"]["custom_name"] =  array (
        
    'name' => 'custom_name',
        
    'type' => 'varchar',
      );
    Then run programatically the repair/rebuild using sugar admin object (I haven't this code now).
    After that the new field is created.
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

  3. #3
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: automatic creation of a field

    Sorry Rafael...but I don't understand you
    Can you put me any example?
    Thanks so much!

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: automatic creation of a field

    Quote Originally Posted by garciasanchezdaniel View Post
    Hello again friends...

    • I'm in the edit view of my custom module (created by the builder module) called illumination


    1. This module, among other fields, have a field 'client' of kynd relationship, with the module called clients
    2. This module will contain many records
    3. My intention is that each time you save a record, automatically create a field 'numbers', in the format: clientname_ILUx, where 'x' is a counter


    For example:

    First record -> clientname_ILU1
    Second record-> clientname_ILU2
    N record-> clientname_ILUN

    What are the steps? I hope your answers
    Thank you very much!
    I don't think this is a good approach.

    Why to create one field for each record?
    What should happen if such table has 1k records? Do you want to automatically create 1k fields? There is no database which support such amount of fields in the same table.

    Is there any other information you want to store with respect to client?

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  5. #5
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: automatic creation of a field

    Sorry, I think I have not explained this too good...
    I want to assign different values, but always assigning to the same field...
    I think I can use logic hook, but I don't know implement this yet
    I don't know which file I must edit... so I hope your answers.
    Thanks

  6. #6
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: automatic creation of a field

    Let us know in detail the workflow behind this feature.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  7. #7
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: automatic creation of a field

    Quote Originally Posted by andopes View Post
    Let us know in detail the workflow behind this feature.

    Cheers
    I want autogenerate a field called 'number' in order to that each record of my custom module has a diferent number, and in list view of my custom module, I will see all my records ordered by this number

    This field will be formed by the value of the field clientname (of the same module) and a counter, beginning in 1

    Daniel

  8. #8
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: automatic creation of a field

    My suggestion:
    Create a custom field in Accounts called client_prefix, type varchar.
    Create an int field in your custom module called client_id
    This field client_id will be rendered in screen as client_prefix + client_id.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  9. #9
    jmuhly is offline Junior Member
    Join Date
    Aug 2011
    Posts
    6

    Default Re: automatic creation of a field

    So this is a string, right? you want, basically, a string that is a mashup of the client's name, and a counter of the number of records this particular client has of this type.

    The logic would have to be some sort of workflow. I.E. when the client field is chosen, a count of the number of records associated with that client would have to be called, with the result, plus one, mashed together with the client's name and an underscore.

    Ok so now i've described what you want to do in english words.

    Step 2 Describe it in steps.

    Condition-client relationship field is filled
    Action--count (list of module records who have this client as related) Return Count
    field data = 'clientname + "_" + Count'

    What's the tools and syntax to do that? I'll leave that to the sugar experts, but hopefully this helps.

  10. #10
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: automatic creation of a field

    Thanks everybody for your replies.
    I solved it by logic hooks!!!
    Thanks

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Automatic activity creation
    By vanipriya in forum Developer Help
    Replies: 4
    Last Post: 2010-12-14, 03:11 AM
  2. Automatic creation of Call from Lead
    By barbward in forum Developer Help
    Replies: 8
    Last Post: 2009-09-27, 04:14 AM
  3. Automatic lead creation
    By gwen in forum Help
    Replies: 3
    Last Post: 2007-09-19, 04:07 PM
  4. Automatic Task Creation
    By Ditto in forum Feature Requests
    Replies: 1
    Last Post: 2004-11-30, 07:42 AM

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
  •