ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Custom Script - Fetching values from different doctype's forms

customization
customize_form
custom_script

#1

Hello, guys!
I’m fairly new to customization and I’m having trouble on something.
I have two doctypes: Doc I and Doc II. Doc I has 4 fields: 2 Data (Data A and Data B) and 2 Int (Int D and Int E). Doc II has 2 fields: 1 Data (Alfa) and 1 Int (Beta).
I’ve made a Custom Script to create a button. When the button is clicked I’m expecting to create a new Doc II form with the values of Data A and Data B fields from Doc I form concatenated in Alfa. Also, the Int values Int D and Int E summed in Beta.
The JS code I’ve used to create the Custom Script is below.
code
I managed to get the expected result for Alfa but I just couldn’t make it work for Beta.
During tests I’ve changed Beta’s type to Data and the value transfer was sucessful.
But I really need Beta’s type to be Int. Is there anyone who knows what I’m getting wrong?
Appreciate your help. :grin::grin:


#2



#3


#4

When Beta’s type is Int


#5

When Beta’s type is Data


#6

I’m also trying to do a similar thing. Developing a custom app and modelling a Document Flow for my company, but I am stuck in the same problem. Can’t make the method frappe.new_doc work.


#7

What if you put a hardcoded int value for beta? If it works then put the sun into a variable before putting the variable into beta


#8

try using parseInt() function