0 votes

Hello girls and guys,

For a data synchronisation i need to update/insert the price's of a product in the table PROD_PRCE. In the excel file i have a product key which I can use to get the specific dataset of the PROD_PRCE and update it:

enter image description here

This works perfect but if there are no prices related to the product I need to insert them and here is where the problem starts.

The table has two keys so in a normal case i would use openEditRelation/insertDetail to insert a new record but there is no entityHandle for LK_CURRENCY. This is the second table where the relation is based on together with the products table.

So is there a way to insert data to this table without using the execSql function?

asked in WorkFlow / Serverscript by (106 points)

1 Answer

0 votes

Hi Bart,

Good question, I actually never tried that myself. Apparently, the PROD_PRCE is a special enitity and it doesn't behave like other entities, for instance updateDetail2 didn't work. However, I managed to make it work using insertDetail2 and doing the update with the detail dataset object.

With the provided snipped, I managed to insert a new product with a price for EURO currency.

Test request:


ServerJs file: serverjs\products\import.js

function main() {
var k_Product = 0,
editProd = Efficy.openEditContext(ntProd, k_Product),
dsProdPrce = Efficy.getDetailDataSet(editProd, ntProdPrce),
dsProd = Efficy.getMasterDataSet(editProd, 0);

dsProd.fieldByName("NAME").asString = "Kristof";
dsProd.fieldByName("PRICE1").asFloat = "1";

Efficy.insertDetail2(editProd, ntProdPrce, 1, false);
dsProdPrce.fieldByName("PRICE").asFloat = 123.45;

Efficy.setUsers(editProd, Efficy.currentUserId(), false, false);
k_Product = Efficy.getEditKey(editProd);

return k_Product;
answered by (6.8k points)
1,165 questions
1,423 answers
325 users