Skip to content

Commit

Permalink
fix migration bugs, handle set fields
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Oct 27, 2023
1 parent 7e98815 commit 7182fa9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/jazkarta/easyformplugin/salesforce/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def prepare_salesforce_data(self, fields, form_input, expr_context):
"""
data = {}
for sf_fieldname, value in fields.items():
if not sf_fieldname:
continue
# evaluate expressions
expr = None
if value.startswith("form:"):
Expand All @@ -138,6 +140,8 @@ def prepare_salesforce_data(self, fields, form_input, expr_context):
if isinstance(value, (date, datetime)):
# serialize dates and datetimes (not handled by json.dumps)
value = value.isoformat()
elif isinstance(value, set):
value = ";".join(value)

data[sf_fieldname] = value
return data
Expand Down
7 changes: 3 additions & 4 deletions src/jazkarta/easyformplugin/salesforce/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ def append_sf_action(schema, type_, name, properties):
raise NotImplementedError("Unsupported creationMode: {}".format(creation_mode))
fields = {}
for item in properties["fieldMap"]:
if "/" in item["field_path"]:
raise NotImplementedError("Fields in fieldset folders not supported yet.")
fields[item["sf_field"]] = "form:" + item["field_path"]
path = item["field_path"].split(',')[-1]
fields[item["sf_field"]] = "form:" + path
for item in properties["presetValueMap"]:
fields[item["sf_field"]] = item["value"]
op = {
Expand All @@ -41,7 +40,7 @@ def append_sf_action(schema, type_, name, properties):
"does not support chained adapters at this time)."
)

append_node(node, "operations", json.dumps([op]))
append_node(node, "operations", json.dumps([op], indent=4))
return node


Expand Down
8 changes: 6 additions & 2 deletions src/jazkarta/easyformplugin/salesforce/prefill.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from zope.schema import getFields
from zope.schema.interfaces import IField
from zope.schema.interfaces import IDate
from zope.schema.interfaces import ISet

from .action import SF_CREDENTIALS
from .interfaces import IJazkartaEasyformpluginSalesforceLayer
Expand Down Expand Up @@ -83,8 +84,11 @@ def query(self):

def get(self):
value = self.query().get(self.sf_field)
if value and IDate.providedBy(self.field):
value = parse(value)
if value:
if IDate.providedBy(self.field):
value = parse(value)
elif ISet.providedBy(self.field):
value = set(value.split(';'))
return value


Expand Down

0 comments on commit 7182fa9

Please sign in to comment.