Hi ,
I have a Problem of looping through set of Records in Rollbase.
I have two objects call order and orderline with relationship 1:M
Each orderline havinga field to hold the Item price.
I have a field in order table Where I need to update this field by adding the all the order lline prices value related to this order.
I have Create a trigger in orderline but it want add all the line price
Code
return rbv_api.selectValue("SELECT SUM({!line_value#value}) FROM orderline WHERE {!R238341#id}= R238341");
Hello,
Can you try this code:
return rbv_api.selectNumber("SELECT SUM(line_value) FROM orderline WHERE R238341=?", parseInt("{!R238341#id}"));
Thank you,
Gian
Hi Gain,
When I debug the Code.
It gives me following Errors
<Error_snip>
Parsed Formula
001 var rbv_api = new Packages.com.rb.core.services.api.ServerSideAPI(169219, 171570);
002
003 function wrapper() {
004 return rbv_api.selectNumber("SELECT SUM(line_value) FROM orderline WHERE R238341=?", parseInt("249605"));
005 }
006 wrapper();
---------------------------------------------------
Error Error in SQL Query
SELECT SUM(line_value) FROM orderline WHERE R238341=?
RB_623: Error preparing statement for query
SELECT SUM(line_value) FROM RB_OBJ_DATA A WHERE A.OBJ_DEF_ID=209137 AND (A.INTG1=?)
[DataDirect][OpenEdge JDBC Driver][OpenEdge] Column "LINE_VALUE" cannot be found or is not specified for query. (13865) (line #4) in formula:
var rbv_api = new Packages.com.rb.core.services.api.ServerSideAPI(169219, 171570);
function wrapper() {
return rbv_api.selectNumber("SELECT SUM(line_value) FROM orderline WHERE R238341=?", parseInt("249605"));
}
wrapper();
<Error_snip>
Hi Gain,
Many thanks for the reply
Problem is in my Code is
return rbv_api.selectValue("SELECT SUM({!line_value#value}) FROM orderline WHERE {!R238341#id}= R238341");
Say For a Given order I have 3 lines.
line item item_value
1 xxx 10
2 yyy 30
3. zzz 40
now Im creating line for
4 ttt 10
Trigger loop for 4 times but it sum line 4 item value for 4 times .
Hi Gain
If I change your code to like this by changing (line_value) to ({!line_value}) it give me the same result as my previous
code.
It goes through the lines. but it sum up the current line value.
Appreciate your help on this
return rbv_api.selectNumber("SELECT SUM({!line_value}) FROM orderline WHERE R238341=?", parseInt("{!R238341#id}"));
Hello,
Can you try doing a selectQuery instead? Just to make sure that we are getting all correct records.
Please use this code as reference:
var arr = rbv_api.selectQuery("SELECT id, line_value FROM orderline WHERE R238341=?", 1000, parseInt(" {!R238341#id}"));
rbv_api.printArr(arr);
Let me know how it goes,
Thank you,
Gian
Hi Gian,
Thanks for the help.
No issue with Query. We get this issue the "line_value" is a formula field. So due to some reason it is not working.
Many thanks for the support.
Hello,
I see. Please be informed that formula fields can't be used in the Query APIs. You can use expression fields instead but expression fields doesn't update the return value automatically.
Thanks,
Gian