It is possible to add conditions to the execution of operations, so that they are only executed if the condition evaluates to true.
To condition the operation, you must do it from the advanced administration.
In the conditions, you can use the same dynamic expressions that you use for example in the fields. Here are some examples.
Condition execution on the value of a boolean field being true
fil.gmv('metadata.mi_campo') == True
#reemplaza mi campo por el nombre interno de tu campo.
Condition the execution on a specific form
fil.doctype.name == "mi_formulario"
#reemplaza mi_formulario por el nombre interno del formulario
Condition the execution to the value of a Choice of type Dictionary
fil.gmv('metadata.mi_campo') == "valor_del_termino"
#reemplaza mi campo por el nombre interno del campo y valor_del_termino por el
valor interno del término del diccionario.
Make execution conditional on the absence of a document feature
not fil.get_feature_value('nombre_de_la_feature')
#reemplaza el nombre de la feature por el valor de la característica, por ejemplo,
feature.text
Condition the value of a date type field to be less than the current date
fil.get_metadata("metadata.mi_campo_fecha").date_value <= datetime.date.today()
#reemplaza "metadata.mi_campo_fecha" por el nombre interno de tu campo de tipo fecha
In this expression with fil.get_metadata() we get the complete metadata object, with .date_value we get the date type value. If you use fil.gmv() you will get only the value of the field as a string.
The expression in the example will only work with Date/Date fields. If you are working with a Datetime/Datetime field, you will have to modify this expression slightly.
fil.get_metadata("metadata.mi_campo_fecha").datetime_value <= datetime.date.today()
#reemplaza "metadata.mi_campo_fecha" por el nombre interno de tu campo de tipo fecha
In this case, we use the .datetime_value property to obtain the datetime value.
Comments
0 comments
Please sign in to leave a comment.