Seth0330 commited on
Commit
daae7a9
·
verified ·
1 Parent(s): af28a7b

Update backend/app/monday_service.py

Browse files
Files changed (1) hide show
  1. backend/app/monday_service.py +10 -9
backend/app/monday_service.py CHANGED
@@ -155,7 +155,7 @@ async def _get_board_columns(board_id: str) -> List[Dict[str, Any]]:
155
  return []
156
 
157
 
158
- def _format_column_value(value: Any, column_type: str, column_id: Optional[str] = None) -> str:
159
  """
160
  Format a value according to Monday.com column type.
161
 
@@ -165,7 +165,8 @@ def _format_column_value(value: Any, column_type: str, column_id: Optional[str]
165
  column_id: Column ID (for special handling)
166
 
167
  Returns:
168
- JSON string formatted for Monday.com API (or plain string for text columns)
 
169
  """
170
  if value is None:
171
  return ""
@@ -173,18 +174,18 @@ def _format_column_value(value: Any, column_type: str, column_id: Optional[str]
173
  value_str = str(value)
174
 
175
  if column_type == "email":
176
- # Monday.com email format requires JSON object with email and text
177
- return json.dumps({"email": value_str, "text": value_str})
178
  elif column_type == "phone":
179
- return json.dumps({"phone": value_str, "countryShortName": "US"})
180
  elif column_type == "link":
181
  # If it's already a URL, use it; otherwise create a link
182
  if value_str.startswith("http://") or value_str.startswith("https://"):
183
- return json.dumps({"url": value_str, "text": value_str})
184
  else:
185
- return json.dumps({"url": f"https://{value_str}", "text": value_str})
186
  else:
187
- # Text, status, and other types - just return the string (not JSON)
188
  return value_str
189
 
190
 
@@ -317,7 +318,7 @@ async def create_monday_lead(
317
  # Convert column_values to JSON string for GraphQL mutation
318
  # Monday.com expects column values as a JSON string where:
319
  # - Text columns: plain string values
320
- # - Email/Phone/Link columns: JSON string values (double-encoded)
321
  column_values_json = json.dumps(column_values)
322
  print(f"[DEBUG] Monday.com column_values JSON: {column_values_json[:500]}")
323
 
 
155
  return []
156
 
157
 
158
+ def _format_column_value(value: Any, column_type: str, column_id: Optional[str] = None) -> Any:
159
  """
160
  Format a value according to Monday.com column type.
161
 
 
165
  column_id: Column ID (for special handling)
166
 
167
  Returns:
168
+ For email/phone/link: Python dict object
169
+ For text/other types: Plain string
170
  """
171
  if value is None:
172
  return ""
 
174
  value_str = str(value)
175
 
176
  if column_type == "email":
177
+ # Monday.com email format requires dict object (will be JSON encoded later)
178
+ return {"email": value_str, "text": value_str}
179
  elif column_type == "phone":
180
+ return {"phone": value_str, "countryShortName": "US"}
181
  elif column_type == "link":
182
  # If it's already a URL, use it; otherwise create a link
183
  if value_str.startswith("http://") or value_str.startswith("https://"):
184
+ return {"url": value_str, "text": value_str}
185
  else:
186
+ return {"url": f"https://{value_str}", "text": value_str}
187
  else:
188
+ # Text, status, and other types - just return the string
189
  return value_str
190
 
191
 
 
318
  # Convert column_values to JSON string for GraphQL mutation
319
  # Monday.com expects column values as a JSON string where:
320
  # - Text columns: plain string values
321
+ # - Email/Phone/Link columns: dict objects (properly JSON encoded)
322
  column_values_json = json.dumps(column_values)
323
  print(f"[DEBUG] Monday.com column_values JSON: {column_values_json[:500]}")
324