- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 06:52 AM
Hello my code in business rule returns 'null' or empty value for every field I am trying to get using getValue();. I have a simple app with two tables (Amount_of_points and Sport_list). What I am trying to do is to setup a business rule which is triggered after I make a update/insert on form with Amount_of_points. On a form I will choose a sport to which I will give a certain number of points and I want those points to be counted in the total amount of the specific sport. Attached script does not work and it is not able to sum anything because field 'amount' is always empty for the busines rule script so I am basically sending nothing to me total number of points. Any idea why I am not able to read fields using getValue();? Thank you.
Script:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 08:12 AM
Update the query condition as follows.
contributionGR.addQuery('sport', current.sport);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:31 AM
Hi, I used this name only as a placeholder for exemplary script but I do have correct name of table, actually the name of my table is x_1298889_sport_amount as it is scoped application so this should not be my problem right now, but thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:30 AM
@Martin_samek Your script log should be inside while block.
You can not retrieve field value before next() method.
try to add log inside while block then you should get the value.
eg:
while (amountGR.next()) {
//even this part is returning 'null' into my log
gs.info("Amount is " + parseInt(amountGR.getValue('amount'), 10));
sum = sum + parseInt(amountGR.getValue('amount'), 10);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:39 AM
If I move the log script into the while I wont get any log message, maybe it is because the while block never starts because the amountGR is empty?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:41 AM
@Martin_samek If there are no records matching with the query then the while will not run.
Also, In which application scope your business rule is defined? In your application scope or in Global scope?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 07:43 AM
@Sandeep Rajput I run the business rule in application scope