Cloning an 'order' record that has a automatic number field for 'ordernumber; field - Forum - Rollbase - Progress Community

Cloning an 'order' record that has a automatic number field for 'ordernumber; field

 Forum

Cloning an 'order' record that has a automatic number field for 'ordernumber; field

This question is not answered

Hello,

I use this code:

var v_oldorder = {!id};

var v_newarr = [];

var v_newnumber =

v_newarr['status'] = 65006;
v_newarr['ordern_ordernumber'] = 0;

var v_neworderid = rbv_api.cloneRecord("order", {!id}, v_newarr);

However the newly created order should get a number based upon the sequence that is in the ordernumber field.

Can someon help?

All Replies
  • Hi guys, anything on this question?

  • Hello Guys, can anyone please give an answer on this question?

    Regards, Wim

  • Sorry. Could you please elaborate your question?

    Thanks

    Srinivas

  • Hi Wim,

    First of all, can you please stop creating new posts for the same issue over and over? I now had to search to find this original post with the actual description of your problem.

    Having said that, this looks like a bug. The API for cloning a record does not seem to look at the 'special abilities' of an auto-number field. I tried the following things:

    - Not adding the auto-number field to my array

    - Add it as a question mark

    - Add it as -1

    All doesn't work (since the actual value -1/? is being used as the auto-number value).

    As a workaround you can probably use createRecord (assigning the cloned values manually) without sending the auto-number value, that should work.

  • Original post in community.progress.com/.../91220

  • If your auto-number field is an integer field you could also do something like this I guess, otherwise, you'd need to cut out the integer part, add +1 and then add the characters to it again:

    var v_newarr = [];
    var arr = rbv_api.selectQuery( "select AutoNumber from Order ORDER by AutoNumber DESC", 1);
    
    var numberpart = arr[0];
    var number = numberpart[0];
    
    v_newarr['Description'] = 'Clone Order';
    v_newarr['AutoNumber'] = number + 1;
    
    createNewRecord(v_newarr);
    
    function createNewRecord(recarr) {
      
      rbv_api.cloneRecord("Order", {!id}, v_newarr);
      
    }

    This apart from the fact that I think the clone api should be aware of auto-numbering....
  • Dear Ruben,
    My apologies fort he inconvenience on this question, but normally you guys are very quick in answering our questions!
    And this question is urgent for our customer.
    Looking at your answer i need to write a lot of code because there are a lot of fields in my ‘order’ record.
    However thanks very much for his answer, i will absolutely try to achieve it the way you describe it.
     
    Regards,  Wim Hassink
    Van: Ruben Dröge [mailto:bounce-rdroge@community.progress.com]
    Verzonden: woensdag 17 augustus 2016 11:24
    Aan: TU.Rollbase@community.progress.com
    Onderwerp: RE: [Technical Users - Rollbase] Cloning an 'order' record that has a automatic number field for 'ordernumber; field
     
    Update from Progress Community
     

    If your auto-number field is an integer field you could also do something like this I guess, otherwise, you'd need to cut out the integer part, add +1 and then add the characters to it again:

    var v_newarr = [];
    var arr = rbv_api.selectQuery( "select AutoNumber from Order ORDER by AutoNumber DESC", 1);
     
    var numberpart = arr[0];
    var number = numberpart[0];
     
    v_newarr['Description'] = 'Clone Order';
    v_newarr['AutoNumber'] = number + 1;
     
    createNewRecord(v_newarr);
     
    function createNewRecord(recarr) {
      
      rbv_api.cloneRecord("Order", {!id}, v_newarr);
      
    }

    This apart from the fact that I think the clone api should be aware of auto-numbering....

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

     
  • What do you mean with a lot of code?

    I am still doing the clone of the record, just offering the 'latest' auto-numbering field value by looking up the highest value available in the order object records. The description field you can forget about.

  • Again sorry, did not study all of your suggestion; will try and let you know.
    (not much code needed indeed)
    Regards, Wim
    Van: Ruben Dröge [mailto:bounce-rdroge@community.progress.com]
    Verzonden: woensdag 17 augustus 2016 12:45
    Aan: TU.Rollbase@community.progress.com
    Onderwerp: RE: [Technical Users - Rollbase] Cloning an 'order' record that has a automatic number field for 'ordernumber; field
     
    Update from Progress Community
     

    What do you mean with a lot of code?

    I am still doing the clone of the record, just offering the 'latest' auto-numbering field value by looking up the highest value available in the order object records. The description field you can forget about.

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.