Skip to content

Instantly share code, notes, and snippets.

@mllavez
Last active December 14, 2022 00:26
Show Gist options
  • Save mllavez/f1fc8ce20bb56505cda9c99c6189f85d to your computer and use it in GitHub Desktop.
Save mllavez/f1fc8ce20bb56505cda9c99c6189f85d to your computer and use it in GitHub Desktop.
/****************************************************************
const createNewCommunity = async (communityName, indigenousAffiliation) => {
try {
const request_variables = {
entity: 'community',
field_values: {
community_field0: communityName,
community_field2: indigenousAffiliation,
},
"forceAsyncPostCreateProcessing": true
};
const full_response_data = await context.freeagent.createEntity(
request_variables
);
if (full_response_data.length === 0){
return {
response: {
data: {},
statusText: 'Internal Server Error',
status: 500,
message: 'Error creating new community',
debug: {
request_variables,
full_response_data,
},
},
};
}
return {
response: {
data: full_response_data[0].data.createEntity.entity_value,
statusText: 'OK',
status: 200,
message: 'New community created',
debug: {
request_variables,
full_response_data,
},
},
};
} catch (e) {
return {
response: {
data: {},
statusText: e.name,
status: 500,
message:
'Error creating new community' + '\n' + e.message + ' ' + e.stack,
},
};
}
};
****************************************************************/
[
{
"data": {
"createEntity": {
"entity_value": {
"__typename": "entityValue",
"id": "c75459e5-118d-4100-9a94-3b1a930767ad",
"cache_key": "list_0_c75459e5-118d-4100-9a94-3b1a930767ad",
"seq_id": "COM101783",
"field_values": null,
"oldestDueTask": null,
"is_editable": null,
"is_deletable": null,
"lines": null
},
"__typename": "createEntity"
}
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment