Frappe call if else statement

I want to get a value in frappe call.But when there is no value is occured i want insert a document and while value is present i want update the value. when if is working and the else is not working .any one plz help me solve the issue

to be more specific, which business case, via js or python script, or hooked python code? what you have tried, what is the current and expected result?