Results 1 to 8 of 8

Thread: Please expand on "customCode" array key

  1. #1
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Please expand on "customCode" array key

    Hello all. This post is a request to do some additional work when needing to append additional information along with an HTML element on an Edit form/page.
    I visited the SugarCRM IRC Channel, and Community Member eggsurplus did mention that he has also requested this feature, so my apologies if this is a duplicate request.

    Anyway, below is the use case:
    In a custom/MODULE/metadata/editviewdefs.php file, I'd like to customize the code so that it appends a value (to go next to) an HTML input form element on the edit screen.

    When I modify the array, adding the key "customCode", I know it will replace the expected rendering of the specified Form Element.

    How do I get the expected rendering PLUS some other text or expression value?

    Note: If the team can get it working, can it be released as a plugin to run in the older versions? Currently we are running 6.2.2 Enterprise Edition.

    Thanks,
    Adam

  2. #2
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Please expand on "customCode" array key

    I am not 100% sure I understand but if you look in modules/Users/metadata/editviewdefs.php you will see that some of the fields have custom codes like this

    PHP Code:
    'customCode' => '{if $IS_ADMIN}@@FIELD@@{else}{$STATUS_READONLY}{/if}'
    and so @@FIELD@@ seems to render the original field code and then you coudl add anything else you want after that like

    PHP Code:
    'customCode' => '@@FIELD@@ <input type=text name=extracode>'
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  3. #3
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Please expand on "customCode" array key

    And that is really awesome! That is one pain point gone. Thanks Ken for pointing that out!

  4. #4
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Re: Please expand on "customCode" array key

    Quote Originally Posted by kbrill View Post
    I am not 100% sure I understand but if you look in modules/Users/metadata/editviewdefs.php you will see that some of the fields have custom codes like this

    PHP Code:
    'customCode' => '{if $IS_ADMIN}@@FIELD@@{else}{$STATUS_READONLY}{/if}'
    and so @@FIELD@@ seems to render the original field code and then you coudl add anything else you want after that like

    PHP Code:
    'customCode' => '@@FIELD@@ <input type=text name=extracode>'
    Hi Ken, thanks for the advice. However, using @@FIELD@@ as you specified did not work. It printed @@FIELD@@ to the screen. Then I tried putting in the actual field name (first in all lower case, and then in all upper case) between the 2 (double at-signs) delimeters. Got same result. it simply printed whatever was between the @@ delimeters to the screen.

    I then ran grep to find any other possible instance of 'customCode' => '@@ and there was none, so in my setup I have no reference.

    Version is Enterprise 6.2.2, and the file I'm trying to use it in, is custom/modules/Opportunities/metadata/editviewdefs.php

    Thanks,
    Adam

  5. #5
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Please expand on "customCode" array key

    Let me look into that, it maybe that someone put in special code to resolve that. I know there is a way to get the field in there.
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  6. #6
    sugarAdam is offline Sugar Community Member
    Join Date
    Dec 2011
    Location
    New York
    Posts
    37

    Default Re: Please expand on "customCode" array key

    Hi Ken, thanks for getting back to me so quickly. I'm currently in the IRC channel as "nylinuxhelp" - and eggsurplus is also there.

    If it saves you any time, eggsurplus mentioned that your proposal (possibly) won't work in my version of Enterprise 6.2.2

    Thanks,
    Adam

  7. #7
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Please expand on "customCode" array key

    No, I just found that its only available in 6.4.0 (all versions). I dont see a way to do this in previous versions without writing some sort of smarty plugin
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  8. #8
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Please expand on "customCode" array key

    I havnt worked out if it works everywhere but it looks like it does. It's code is in the file include/Smarty/plugins/function.sugar_evalcolumn.php
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 2011-02-08, 06:05 PM
  2. Editing Type "Date" in customCode
    By banning in forum Help
    Replies: 0
    Last Post: 2010-08-10, 06:35 PM
  3. Help with customcode in field of type bool "checkbox"
    By Rodolfo Lima Jesus in forum Help
    Replies: 2
    Last Post: 2010-03-18, 02:02 PM
  4. customCode to add onclick="some_javascript();" to fields...
    By ps146training in forum Developer Help
    Replies: 3
    Last Post: 2008-11-20, 03:18 AM

Tags for this Thread

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
  •