Hello All,
how can i fetch a grid row value , Sum them and assign summation value into formula field .
( A grid may have 1, 2 or more row depend on requirement ) . if Detail required about object please let me know.
thanks.
Hi John,
Please specify a function getSumOfRowValues() in "onSubmit" event handler by following the below navigation.
Object Definition->Pages->New->Properties
Add a script component in the new record page by using design the page and define the function as follows.
<script>
function getSumOfRowValues(){
var sumOfRowValues=rbf_sumGridColumn2(0, "marks");
rbf_setFieldValue("Sum", (sumOfRowValues));
}
</script>
The function rbf_sumGridColumn2(0, "marks"); will return the sum of all the values of the field "Marks".
And the function rbf_setFieldValue("Sum", (sumOfRowValues)); will set the value to field of type "integer".
Note: Formula field cannot be saved via script component.
Please let me know if this fits your requirement.
Regards,
Shiva
Hi Shiva ,
Thanks. I'll try and get that working.
Hello All,
can any one suggest that how can i assign calculated grid row value into field of another object.
let say i have two object Obj1 and Obj2 .
Obj1 has relationship ( one Obj1 to many Obj2 ) and field of Obj2 is rating configured in grid now
i calculate sum of all rating using
<script>
function getSum()
{
var sum=rbf_sumGridColumn2(0, "rating");
}
</script>
and i want value of sum should be assigned into Avg field of Obj1 .
i use rbf_setFieldValue('Avg ' , sum ); but didn't get any result.
thanks.
Hi John,
Are you trying to assign the value of 'sum' to formula field 'Avg?'
Regards,
Shiva
Hi Shiva ,
no , its a simple decimal field (avg) . please suggest how can i do for both decimal field as well as
formula field also .
thanks.
Hi John,
If your object uses both Average(decimal type) and Formula Field then you can use the server side API to get the value of Average and assign it to formula field.
Example: In formula field section include the following code.
var id="{!id}";
var arr=rbv_api.selectQuery("SELECT Average FROM ObjA where id=?", 1, {!id});
return arr[0][0];
Attaching app.xml for your reference. Please let me know incase you need any assistance.
Regards,
Shiva
[View:/cfs-file/__key/communityserver-discussions-components-files/25/SampleGridControl_5F00_v2.xml:320:240]