Announcement

Collapse
No announcement yet.

Copy Invoice address to shipment address DO NOT WORKS...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy Invoice address to shipment address DO NOT WORKS...

    Dear All,

    I have a COPY button with the following code inside.
    The aim is to copy the invoice address into shipping address.
    Everything works well but at the end SC do not write data to destination shipping fields :

    {ShipName} = {address_string[0][0]};
    {ShipAddress} = {address_string[0][1]}; {ShipCity} = {address_string[0][2]}; {ShipRegion} = {address_state[0][0]};
    {ShipPostalCode} = {address_string[0][3]}; {ShipCountry} = {address_country[0][0]};

    What I'm wronging ? Why eco has all the right values but final assignment do not work ?
    Has I to use SQL command UPDATE ?
    Bye
    Giovannino


    //Copy all data about customer into Ship to fields
    $check_sql = "SELECT CompanyName, Address, City, State, PostalCode, Country FROM customers WHERE CustomerID = ". {CustomerID} ;
    sc_lookup(address_string, $check_sql);

    echo " RAG SOC " . {address_string[0][0]} ;

    if (isset({address_string[0][0]})) // Row found
    {
    $check_sql_state = "SELECT description FROM counties where county_ID =". {address_string[0][3]} ;
    sc_lookup(address_state, $check_sql_state);
    echo " <br/> STATO " . {address_state[0][0]} ;
    $check_sql_country = "SELECT description FROM countries where country_ID =". {address_string[0][5]} ;
    sc_lookup(address_country, $check_sql_country);
    echo " <br/> NAZIONE " . {address_country[0][0]} ." - ".{address_string[0][1]}." - ".
    {address_string[0][2]}." - ". {address_state[0][0]}." - ".{address_string[0][3]}." - ". {address_country[0][0]};

    {ShipName} = {address_string[0][0]};
    {ShipAddress} = {address_string[0][1]}; {ShipCity} = {address_string[0][2]}; {ShipRegion} = {address_state[0][0]};
    {ShipPostalCode} = {address_string[0][3]}; {ShipCountry} = {address_country[0][0]};

    echo " <br/> Ship name e address ". {ShipName}. " - " .{ShipAddress} ;

    }
    else // No row found
    {
    sc_alert("Attenzione dati Cliente non esistenti !!");
    }

  • #2
    Re: Copy Invoice address to shipment address DO NOT WORKS...

    Hello,

    You can use sc_exec_sql to run Update statements.

    As to why it isn't updating it is probably why you aren't running the Update statement on your RDBMS.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Re: Copy Invoice address to shipment address DO NOT WORKS...

      Hi and thanks,

      so you are saying that without an sql UPDATE I'm not able to populate related fields.
      I thoght that if you later would click on classic update button the RDMS would do the DB update.

      My willing was to make appear the values on {ShipName}.... and others and them push the update button.
      Is it not possible ?

      Comment


      • #4
        Re: Copy Invoice address to shipment address DO NOT WORKS...

        Hi,
        i suppose you have created a PHP-button, if not please correct me.

        It doesn't work that way because you are leaving the page and all your field variables are gone.
        You have to use global variables or an array and fill your fields with those values on reload.

        i.e. In your button code:
        [glb_ShipName] = {address_string[0][0]};

        In the onLoad event:
        if(isset([glb_ShipName]))
        {
        {ShipName}=[glb_ShipName];
        sc_reset_global([glb_ShipName]);
        }

        Hope this helps
        jsb

        Comment


        • #5
          Re: Copy Invoice address to shipment address DO NOT WORKS...

          Hi JsBinca,

          you're great ! Better than perfect !!!! BANG !
          Sorry for my late on reply but I've just connected to forum today after same time.
          Thanks again
          Giovannino

          Comment


          • #6
            Re: Copy Invoice address to shipment address DO NOT WORKS...

            Oopss !

            I talked before to see the end....
            It works perfectly but now I have the problem that later the copied data are not saved.
            When I push on Save button I thought that also data copied would be saved but it is not true
            Which can be the problem now ?
            See stepped images
            Attached Files

            Comment

            Working...
            X