How to use CopyDataFrom to add a new record?


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
You are welcome Aaron.



There is also an enhancement request to add a property or flag to the BO.CopyDataFrom to update the row state in a single pass. Hope to see that enhancement soon Wink

Edhy Rijo

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Hi Edhy,



Thanks for that - it worked Smile



Think I was getting hung up on trying to make the BO change editing state to adding. This method doesn't need that at all.



Thanks again.



Aaron
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Aaron,



When you use the BO.CopyDataFrom() it will ignore the Row State so you will need to loop the copied records and set the Row State, the code below should do the trick:



For Each StockBO As bizTransactionItemsStock In Me.BizTransactionItemsStock1.GetEnumerable()

StockBO.CurrentRow.SetAdded()

Next





Edhy Rijo

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Hi,



I am trying to use the CopyDataFrom method to copy the contents of one BO into an empty second BO and to then assign new primary keys to the second BO so that I can add them as new records. However, when I do this and save, it overwrites the original records with the new primary keys and no new records are added.



I think I am missing something to get the records in the second BO added instead of updated.



Is this the best way to take a record and duplicate it? If so, have I missed something?



Thanks in advance,



Aaron

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search