Skip to content

Commit

Permalink
Fix fallback to normal default value adapter (#8)
Browse files Browse the repository at this point in the history
* Fix fallback to normal default value adapter

* fix
  • Loading branch information
davisagli authored Jan 18, 2024
1 parent a4987a1 commit 2e6f371
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/jazkarta/easyformplugin/salesforce/prefill.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def _prefill_value_factory(adapter, context, request, view, field, widget):
fields = operation.get("fields", {})
for sf_field, expr in fields.items():
if expr == "form:%s" % field.__name__:
return SalesforcePrefillValue(form, field, operation, sf_field)
adapter = SalesforcePrefillValue(form, field, operation, sf_field)
value = adapter.get()
if value is not None:
return adapter
break

# Didn't find one, fall back to less specific adapter
# Didn't find a value, fall back to less specific adapter
adapter = superAdapter(
IJazkartaEasyformpluginSalesforceLayer,
adapter,
Expand Down Expand Up @@ -83,6 +87,11 @@ def query(self):
where = self.operation["match_expression"]
if where.startswith("python:"):
where = get_expression(self.form, where, now=DateTime().ISO8601(), sanitize_soql=sanitize_soql)
if not where:
if self.operation.get("action_if_no_existing_object") == "create":
return {}
else:
raise Exception("Not querying Salesforce, because match_expression is empty")
soql = "SELECT {} FROM {} WHERE {}".format(", ".join(fields), sobject, where)
item = self.query_cache.get(soql)
if item is None:
Expand Down

0 comments on commit 2e6f371

Please sign in to comment.