Results 1 to 6 of 6

Thread: How to get field value when user click a custom button

  1. #1
    rob78 is offline Senior Member
    Join Date
    Apr 2009
    Posts
    22

    Default How to get field value when user click a custom button

    I have created custom module which have two fields, supplier_name and customer_name.
    I also create a custom button in detailview called getRecord.
    At the moment I need to get the value entered by user when I click the button

    PHP Code:
    array (
      
    'DetailView' => 
      array (
        
    'templateMeta' => 
        array (
          
    'form' => 
          array (
            
    'buttons' => 
            array (
              
    => 'EDIT',
              
    => 'DUPLICATE',
              
    => 'DELETE',
              
    =>
              array (
                
    'customCode' => '<input type="button" value="getRecord" name="button" onClick={field_Value};/>',
              ), 
    I just want to echo it for the moment just to see if i can reference the field, then I will continue with other part which is creating webservice response which includes the field values and post it.
    Can you please help me out here

  2. #2
    rob78 is offline Senior Member
    Join Date
    Apr 2009
    Posts
    22

    Default Re: How to get field value when user click a custom button

    Any help on this guys? will appreciate this.

  3. #3
    akkimca's Avatar
    akkimca is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    270

    Thumbs up Re: How to get field value when user click a custom button

    hi...

    try this code..
    may be help u........
    PHP Code:
    array (
      
    'DetailView' => 
      array (
        
    'templateMeta' =>
         
    'javascript' =>"function check(){alert('yes');}"
        array (
          
    'form' => 
          array (
            
    'buttons' => 
            array (
              
    => 'EDIT',
              
    => 'DUPLICATE',
              
    => 'DELETE',
              
    =>
              array (
                
    'customCode' => '<input type="button" value="getRecord" name="button" onClick="check()";/>',
              ), 

    all d best
    Regards
    ==========================
    akkimca
    Work as Sugarcrm Freelancer
    Feel free to Find me in skype. Its my pleasure to talk with you.
    ID: akshay.biztech

  4. #4
    rob78 is offline Senior Member
    Join Date
    Apr 2009
    Posts
    22

    Default Re: How to get field value when user click a custom button

    Hi,
    Thanks for the reply
    This did not work.

    I did get the alert working before i started this thread by using.
    array (
    'customCode' => '<input type="button" value="getRecord" name="button" onClick="alert(\'helloworld\');"/>',
    But what i want to do is to get reference from the field values so i can construct XML to pass to webservice. So put alert() function aside (I was using alert function since its easier to debug if I actually got the field value), can I create such xml using php
    e.g.. this is done using java script by my colleague who is using Dynamics CRM. I just want to do the same thing in sugarCRM by either modify this calling the same javascript if possible, or generating the same thing using PHP.

    PHP Code:
    // *** Generate the supplier details
    sSupplier "<SupplierAddress>";

    // Process the supplier name field
    sValue "";

        
    sValue $fields.new_supplier.Value

    sSupplier += "<SupplierName>" sValue "</SupplierName>"

    // Process the supplier contact field
    sValue "";

        
    sValue $fields.new_suppliercontact.Value
    }
    sSupplier += "<SupplierContact>" sValue "</SupplierContact>"

    // Process the supplier group field
    sValue "";

    sValue $fields.new_suppliergroupid.Value;

    sSupplier += "<SupplierGroupId>" sValue "</SupplierGroupId>"
    sRoutingGrpID sValue

    sSupplier += "</SupplierAddress>"
    This is an example of what I want to do.
    After constructing this xml return, I will get the commands to send this to webservice, which accept 2 parameters. Header and payload. the payload is the xml contructed above.
    I just want to get the first step done, which is to get $fields.new_supplier.Value returning value. That is why i was using alert.
    Can you help please, as I desperately need help with this.
    Thanks

  5. #5
    rob78 is offline Senior Member
    Join Date
    Apr 2009
    Posts
    22

    Default Re: How to get field value when user click a custom button

    The reference to the field is working now. I was suppose to put {} around the fields.new_supplier.value.

    If anybody can help with creating a responce as i described above, it will be great. how to embed javascript on php, so I can just use the existing javascript that I have.

  6. #6
    rob78 is offline Senior Member
    Join Date
    Apr 2009
    Posts
    22

    Default Re: How to get field value when user click a custom button

    Anybody please. ???

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 2009-03-02, 09:12 AM
  2. Replies: 0
    Last Post: 2008-08-01, 12:48 AM
  3. how to create pop-up on click of select button
    By jenifer in forum Developer Help
    Replies: 2
    Last Post: 2008-07-16, 12:27 PM
  4. How to put a user field with a select button or dropdown
    By sugarcare in forum Developer Help
    Replies: 1
    Last Post: 2006-05-01, 03:08 PM
  5. Replies: 6
    Last Post: 2006-02-03, 03:17 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
  •