⚠️ Warning: Running this Data Block with a value will insert the values into Assette. Use only when you intend to persist new organization records. See
The Organization Add (OrganizationAdd) Data Block in Assette is a user-editable Transform block that facilitates the insertion of new organization records into both the local database and Salesforce. It performs key validations—checking for required parameters and ensuring uniqueness of Code
and Domain
fields after filtering common URL prefixes. This block is typically used by administrators or automated workflows to add new clients or institutions to the organization master list.
General Info #
Field | Value |
---|---|
Name | OrganizationAdd |
Block Category | Transform |
Block Type | Python |
Output Type | Data Table |
Public Block | True |
Editable | Editable |
Definition #
#Organization Add Block
def fn_replace_domain(DomainReplaceList,domain_string):
if len(DomainReplaceList)>0:
for val in DomainReplaceList:
if val in domain_string:
domain_string = str(domain_string).replace(val,"")
return domain_string
def fn_is_code_domain_exists(OrganizationList,Code,Domain,DomainReplaceList):
global fn_replace_domain
IsCodeExists = False
IsDomainExists = False
if len(OrganizationList)>0:
for org in OrganizationList:
domain_string = fn_replace_domain(DomainReplaceList,(org.get("Domain") or ""))
if (org.get("Code") or "")==Code:
IsCodeExists = True
if str(domain_string).lower()==str(Domain).lower():
IsDomainExists = True
if IsCodeExists and IsDomainExists:
break
return IsCodeExists,IsDomainExists
InsertParams = {}
RequiredParamsList = ["Code","Name","Domain"]
DomainReplaceList = ["https://www.","http://www.","http://www","https://","http://"]
replaced_domain = ""
if len(params) > 0:
for key, value in params.items():
if str(key).lower() =="domain":
replaced_domain = fn_replace_domain(DomainReplaceList,value)
if value:
InsertParams[key] = value
if (InsertParams.get("Domain") or "") !="":
InsertParams["Domain"] = replaced_domain
#Validate
Output = []
MissingParamList = []
IsValidRequest = True
if len(RequiredParamsList)>0:
for key in RequiredParamsList:
if (InsertParams.get(key) or "")=="":
MissingParamList.append(key)
if len(MissingParamList)>0:
IsValidRequest = False
comma_separated_string = ", ".join(MissingParamList)
response["errors"] = ["The following parameters have not been provided: " + comma_separated_string]
#Check Parameters existence.
if IsValidRequest:
ReadOutput = read("OrganizationMaster",{})
IsCodeExists,IsDomainExists = fn_is_code_domain_exists((ReadOutput.get("data") or []),(InsertParams.get("Code") or ""),(InsertParams.get("Domain") or ""),DomainReplaceList)
if IsCodeExists:
IsValidRequest = False
if(len(response.get("errors") or [])>0):
response["errors"].append("Code: "+ (InsertParams.get("Code") or "") +" already exists")
else:
response["errors"] = ["Code: "+ (InsertParams.get("Code") or "") +" already exists"]
if IsDomainExists:
IsValidRequest = False
if(len(response.get("errors") or [])>0):
response["errors"].append("Domain: "+ (InsertParams.get("Domain") or "") +" already exists")
else:
response["errors"] = ["Domain: "+ (InsertParams.get("Domain") or "") +" already exists"]
if IsValidRequest:
Output = read("OrganizationAdd",InsertParams)
if "data" in Output.keys():
Output = Output.get("data") or []
response["data"] = Output
Columns #
Column Name | Required | Description |
---|---|---|
Id | No | Internal text identifier (if returned) |
Code | Yes | Unique text-based identifier for the organization |
Name | Yes | Full name of the organization |
Domain | Yes | Website domain, used to ensure uniqueness |
Phone | No | Optional phone contact information |
Request Parameters #
Parameter Name | Display Name | Data Type |
---|---|---|
Code | Code | Text |
Name | Name | Text |
Domain | Domain | Text |
Phone | Phone | Text |
Example Request #
{
"Code": "Telos Brothers",
"Name": "Telos Brothers",
"Domain": "telosbrothers.com",
"Phone": ""
}
Example Response #
The following code shows an example response when the insert is successful.
{
"data": [
{
"rows": 1
}
],
"errors": [],
"success": true,
"logs": [],
"sources": []
}