If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#50540 by weblike
Sat Mar 09, 2019 6:36 pm
I'm curious how others are doing DUPLICATE records.

I have Invoice BO which has Invoice.Series as reference .
On each new Invoice the user can select from multiple Series(dropdown)-> and Series.CurrentNumber is incremented by 1.
I want to duplicate one Invoice for a specific Customer-> the user to be capable to select any Series, but on duplicated Invoice the Customer data (name, address) should be cloned form old invoice.

Thank you.
#50548 by ACDC
Mon Mar 11, 2019 6:16 pm
I haven't given much time to your explanation but this example is how I Create an Invoice from a Quote, both the objects are almost the same, so for your purpose you need to change the reference in the example to Quote to Invoice and QuoteItems to InvoiceItems
Also because its the same object i.e Invoice to Invoice, you may have to use "This" and "That" in the setup


Process No1
--------------------------------------
Rule 1
CREATE Invoice WITH Invoice.Account=Quote.Account,
Invoice.Description=Quote.Description,
Invoice.Contact=Quote.Contact,
Invoice.Quote=Quote,

Rule 2
FIND QuoteItem WHERE QuoteItem IN Quote.Items

Rule 3
CreateInvoiceItemWithQuoteItem (this is a process see contents below)
----------------------------------------------
Process No 2: (Invoice and QuoteItems are set as process inputs on the process)

Rule 1
CREATE InvoiceItem WITH InvoiceItem.Invoice=Invoice,
InvoiceItem.ProductCode=QuoteItem.ProductCode,
InvoiceItem.Quantity=QuoteItem.Quantity,
InvoiceItem.SellingPrice=QuoteItem.SellingPrice,
InvoiceItem.Description=QuoteItem.Description,
InvoiceItem.Discount=QuoteItem.Discount,
InvoiceItem.DeliveryCharge=QuoteItem.DeliveryCharge,
InvoiceItem.TaxPercentage=QuoteItem.TaxPercentage,
InvoiceItem.Notes=QuoteItem.Notes,
InvoiceItem.QuoteItemId=QuoteItem.ID


Hope that makes sense and lets you find a way
#50549 by weblike
Mon Mar 11, 2019 6:24 pm
Thank you for your reply.
I have tried to use This That and the process to have the input of "Invoice", but what happens is Series.CurrentNumber becomes "null" in DB.

My process is like this:
Rule1
FIND Series WHERE Series.DefaultSerie='Yes'

Rule2
If SEARCH_COUNT>0 Then
ENTER NEW Invoice WITH Invoice.Serie=ThisSeries USING 'Select Series'


Rule3
Invoice.Sequence_No=Invoice.Serie.CurrentNumber


Rule4
INCREASE Invoice.Serie.CurrentNumber BY 1


Rule5
EDIT Invoice USING Main
#50550 by ACDC
Mon Mar 11, 2019 6:39 pm
I would try remove this from your process "INCREASE Invoice.Serie.CurrentNumber BY 1"
and place the rule on the Object

If Invoice IS NEW then
INCREASE Invoice.Serie.CurrentNumber BY 1
(or whatever condition needs to apply)
#50551 by Jaymer
Mon Mar 11, 2019 6:49 pm
george,
i took a different approach.
i create the new invoice header for the customer, and then copy lines from existing. I let the use PICK FROM to select the older invoice.

i think it was too much problems when i tried it the original way.
problems with THIS and THAT just did not work - after many hours, and maybe thought it was Aware bug, I gave up and tried my different approach.
now am happy

jaymer...
#50555 by weblike
Tue Mar 12, 2019 8:19 am
ACDC wrote:I would try remove this from your process "INCREASE Invoice.Serie.CurrentNumber BY 1"
and place the rule on the Object

If Invoice IS NEW then
INCREASE Invoice.Serie.CurrentNumber BY 1
(or whatever condition needs to apply)

I had this line in Object before, but that lead to duplicate invoice numbers when 2 or more users were creating in same time.
Since I moved this line in process the duplicate numbers are gone.

Jaymer wrote:george,
i took a different approach.
i create the new invoice header for the customer, and then copy lines from existing. I let the use PICK FROM to select the older invoice.

i think it was too much problems when i tried it the original way.
problems with THIS and THAT just did not work - after many hours, and maybe thought it was Aware bug, I gave up and tried my different approach.
now am happy

jaymer...

Yes the This That thing is above my understanding, sometimes is doing right sometimes not (in my case at least).
I have struggled with this process which sometimes works sometimes not:

Code: Select allFIND Series WHERE Series.DefaultSerie='Yes'
If SEARCH_COUNT>0 Then ENTER NEW Invoice WITH ThatInvoice.Serie=ThisSeries USING 'Select Series'
ThatInvoice.Sequence_No=ThatInvoice.Serie.CurrentNumber
ThatInvoice.Customer=ThisInvoice.Customer
INCREASE ThatInvoice.Serie.CurrentNumber BY 1
EDIT ThatInvoice USING Main

Selection_451.png
Selection_451.png (23.3 KiB) Viewed 206 times
#50556 by ACDC
Tue Mar 12, 2019 10:46 am
I had this line in Object before, but that lead to duplicate invoice numbers when 2 or more users were creating in same time.
Since I moved this line in process the duplicate numbers are gone.


If you put it back on the object does it work ?
#50557 by weblike
Tue Mar 12, 2019 12:27 pm
ACDC wrote:
I had this line in Object before, but that lead to duplicate invoice numbers when 2 or more users were creating in same time.
Since I moved this line in process the duplicate numbers are gone.


If you put it back on the object does it work ?

Same result.
The problem with Process above is that, no matter what Invoice I select to duplicate it puts the same Customer on it even the Input->Invoice has other customer.
The Serie is ok.
#50569 by Markfre1
Fri Mar 15, 2019 4:44 am
I don't know why I didn't look on the forum earlier. I was using the Duplicate function which duplicated the header perfectly and bumped up the invoice # automatically. I used the Duplicate function to duplicate the lines and that seems to work perfectly. Then as I did more, on certain invoices it would get the wrong lines. Since the docs are scant on this, I thought I was doing it incorrectly and tried for two hours. Using the Duplicate function is 2 lines of code (one for header and one for lines), so I sent to support my code to see if I am doing it incorrectly. Otherwise, I guess I have to read the lines of the old and create the new?

Mark F

Who is online

Users browsing this forum: No registered users and 25 guests