Client Script to make fields read only

Is it possible to set fields as read-only status during form loading if certain conditions are met?

I find this may be useful for non-submission forms like "Customer Issues" and "Campaign", where we would like the form to be locked down from further edits once a certain status is set. 

For example, if a Customer Issue is "Closed", then all the fields should be set to read only, since -- well -- it's closed.



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.


2013/11/25 lxnow <la...@union.ph>
Is it possible to set fields as read-only status during form loading if certain conditions are met?

I find this may be useful for non-submission forms like "Customer Issues" and "Campaign", where we would like the form to be locked down from further edits once a certain status is set.

For example, if a Customer Issue is "Closed", then all the fields should be set to read only, since -- well -- it's closed.



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.




--

Maxwell Morais
Tecnologia da Informação
+55 11 3931-1412 Ramal 31

www.realizemodulados.com.br



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.
Thanks again Max.  What does the portion

doc.__islocal ? 0 : 1

mean? I feel this is what I need to change to check for field value status == "Closed"... I'm going to try out the below a little later:
cur_frm.cscript.custom_refresh = function(doc) {
    cur_frm.set_df_property("myfield", "read_only", doc.status == "Closed");
}

On Monday, November 25, 2013 1:25:45 PM UTC+8, Maxwell wrote:


2013/11/25 lxnow <la...@union.ph>
Is it possible to set fields as read-only status during form loading if certain conditions are met?

I find this may be useful for non-submission forms like "Customer Issues" and "Campaign", where we would like the form to be locked down from further edits once a certain status is set. 

For example, if a Customer Issue is "Closed", then all the fields should be set to read only, since -- well -- it's closed.



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.




--

Maxwell Morais
Tecnologia da Informação
+55 11 3931-1412 Ramal 31

 www.realizemodulados.com.br



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.

doc.__islocal === 1

The document exists only in the current browser session
doc.__islocal === 0

The document exists in database too, or the document is already saved

2013/11/25 lxnow <la...@union.ph>

Thanks again Max. What does the portion

doc.__islocal ? 0 : 1

mean? I feel this is what I need to change to check for field value status == "Closed"... I'm going to try out the below a little later:

cur_frm.cscript.custom_refresh = function(doc) {
cur_frm.set_df_property("myfield", "read_only", doc.status == "Closed");
}


On Monday, November 25, 2013 1:25:45 PM UTC+8, Maxwell wrote:


2013/11/25 lxnow <la...@union.ph>

Is it possible to set fields as read-only status during form loading if certain conditions are met?

I find this may be useful for non-submission forms like "Customer Issues" and "Campaign", where we would like the form to be locked down from further edits once a certain status is set.

For example, if a Customer Issue is "Closed", then all the fields should be set to read only, since -- well -- it's closed.



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.




--

Maxwell Morais
Tecnologia da Informação



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.

--

Maxwell Morais
Tecnologia da Informação



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.