I populated a SDT with data in Genexus 15 and need to save it on a transaction. The SDT has a two level structure with header information and detail items.
I tried with this DataProvider but something is wrong, because I get an foreign key violation error when tring to execute it:
Rules:
parm(in: &NewInvoice); // SDT variable
Source:
DPInvoice
{
StampId = &NewInvoice.StampId
InvoiceNumber = &NewInvoice.InvoiceNumber
CustomerId = &NewInvoice.CustomerId
Concept
{
ProductId = &NewInvoice.Concept.CurrentItem.ProductId
ConceptQty = &NewInvoice.Concept.CurrentItem.ConceptQty
}
}
The Event triggering the DP in the webpanel:
&Invoice = DPInvoice(&NewInvoice)
&Invoice.Insert()
commit
This is the transaction structure
Please help me!
You have to iterate over the second level of &NewInvoice
.
Define a variable &NewInvoiceItem
of type SDTInvoiceCopy1.ConceptItem
in the DataProvider and use the following Source code:
DPInvoice
{
StampId = &NewInvoice.StampId
InvoiceNumber = &NewInvoice.InvoiceNumber
CustomerId = &NewInvoice.CustomerId
Concept Input &NewInvoiceItem in &NewInvoice.Concept
{
ProductId = &NewInvoiceItem.ProductId
ConceptQty = &NewInvoiceItem.ConceptQty
}
}