Server Side Script for Field Calculation

Dear All,

Need assistance on server side scripting on the field calculation.

Scenario :

  1. I need to calculate Pending Billing ( Sales Order - Sales Invoice)

I did add in client side scripting. Its work on the calculation but seem its does not appear the latest update figure in other doctype ( like purchase order/ Invoice) without hitting save button at project side first.

Anyone would like to share your sample of server side scrip on the field calculation.

Appreciate on the input.

Thank you

Regard
Charnack

first make sure server_script_enabled set as 1 in config,

bench set-config server_script_enabled 1

create a new server script for doctype Project, for before save doc event

script code as
doc.pending_billing_amount = doc.total_sales_amount - doc.total_billed_amount

1 Like

Hi Szifisher,

Update on the script. I had disable client script and enable server script as your guide but seem like the pending billing field does not update accordingly when sales invoice is submitted.

But its work fine when I cancel the invoice. The field will update accordingly. Any advice.

Thank you

Regards
Charnack