How to add data in a field (with datatype of data) based on the value of another field

Hello all,

I would like to add some data in a field based based on the value of another field.

For example the idea is like if a user selects country 'France', the capital field should automatically be filled with 'Paris'.
I tried to achieve that with a custom script but nothing. I would like suggestions on what should be the data type for those fields and the condition for the custom script because there will be more than one country.

Thank you much for your help.

Regards,
Kat.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
Your query is very confusing. Your country selection field should be of type "Select" and capital "Data"

What is the custom script you tried?

On Monday, December 30, 2013 12:59:12 PM UTC+5:30, Kat wrote:
Hello all,

I would like to add some data in a field based based on the value of another field.

For example the idea is like if a user selects country 'France', the capital field should automatically be filled with 'Paris'.
I tried to achieve that with a custom script but nothing. I would like suggestions on what should be the data type for those fields and the condition for the custom script because there will be more than one country.

Thank you much for your help.

Regards,
Kat.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
Hi Rushabh,

Thanks for your reply.

I tried a script like this one:

cur_frm.cscript.custom_validate = function(doc){

        if (doc.country = 'France'){
                doc.cap_city = 'Paris')
        }
}

But I don't get the expected result. And to clarify a bit the question, I would say if we are dealing with 5 countries, how should the condition be written? 

Regards.

On Monday, December 30, 2013 12:53:28 PM UTC+2, rushabh wrote:
Your query is very confusing. Your country selection field should be of type "Select" and capital "Data"

What is the custom script you tried?

On Monday, December 30, 2013 12:59:12 PM UTC+5:30, Kat wrote:
Hello all,

I would like to add some data in a field based based on the value of another field.

For example the idea is like if a user selects country 'France', the capital field should automatically be filled with 'Paris'.
I tried to achieve that with a custom script but nothing. I would like suggestions on what should be the data type for those fields and the condition for the custom script because there will be more than one country.

Thank you much for your help.

Regards,
Kat.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.