Hi all,
Problem Statement: I want to store location coordinates of user closing a task in the ToDo doctype. Client script I have created for the same is working fine and I can see the results in the console. But corresponding server script is not working.
Server Script (Type: API)
def fetch_location(todo_id, latitude, longitude):
# Force an error for debugging
frappe.throw(“Intentional Error: This is for debugging purposes”)
# Log the received data for debugging purposes
frappe.log_error(f"Received Latitude: {latitude}, Longitude: {longitude} for ToDo: {todo_id}", "Location Update")
# Fetch the ToDo document by its name (id)
todo = frappe.get_doc("ToDo", todo_id)
# Update the latitude and longitude fields
todo.custom_latitude = latitude
todo.custom_longitude = longitude
# Save the updated document
todo.save()
# Return a success message
return {"message": "Location updated successfully", "latitude": latitude, "longitude": longitude}
Even a simple test script such as following is also throwing undefined response in console:
def test_script():
return {“message”: “Test successful”}
What I have already done:
Please guide if this kind of customization via server script is feasible without doing any code setup and just by updating client/server scripts via UI. If yes, where am I going wrong?