Should I specify the object id in the 'object' key when adding activities.
How is this key used by stream exactly, is uniqueness required in this field? For me it's not so important since with the foreign_id I can get back all the information from the actor verb, object, target etc.. during the enrichment process.
If I only specify "$objectType" instead of "$objectType:$objectId" could this cause problems?
$data = [
'actor' => '1',
'verb' => "$verb",
// This
'object' => "$objectType",
// Or This
'object' => "$objectType:$objectId",
'target' => "$targetObjectType:$targetObjectId",
'time' => "$time",
'foreign_id' => "$foreignId",
// Custom field
'object_type' => $objectType
];
Object doesn't have to be unique. Foreign id should be unique though. (as it's used for determining uniqueness and we allow you to delete activities by foreign id)
I would recommend using objectType:objectId as this will make it easier for you to enrich the data (query any missing information from your DB) if that's necessary.
Related
I am trying to delete and update records in cosmosDB using my graphql/nodejs code and getting error - "Entity with the specified id does not exist in the system". Here is my code
deleteRecord: async (root, id) => {
const { resource: result } = await container.item(id.id, key).delete();
console.log(`Deleted item with id: ${id}`);
},
Somehow below code is not able to find record, even "container.item(id.id, key).read()" doesn't work.
await container.item(id.id, key)
But if I try to find record using query spec it works
await container.items.query('SELECT * from c where c.id = "'+id+'"' ).fetchNext()
FYI- I am able to fetch all records and create new item, so Connection to DB and reading/writing is not an issue.
What else can it be? Any pointer related to this will be helpful.
Thanks in advance.
It seems you pass the wrong key to item(id,key). According to the Note of this documentation:
In both the "update" and "delete" methods, the item has to be selected
from the database by calling container.item(). The two parameters
passed in are the id of the item and the item's partition key. In this
case, the parition key is the value of the "category" field.
So you need to pass the value of your partition key, not your partition key path.
For example, if you have document like below, and your partition key is '/category', you need to use this code await container.item("xxxxxx", "movie").
{
"id":"xxxxxx",
"category":"movie"
}
We are using the REST API to Upsert customer record. Included in the PUT is the address record.
Everytime we send the PUT, the customer record is updated as expected. The problem is that every time we run the request, a new address is added to the address book.
"companyName"=> $result['CLIENTNAME'],
"email"=> '',
"emailPreference"=> "PDF",
"emailTransactions"=> false,
"externalId"=> $netsuiteCustomerId,
"isinactive"=> false,
"phone"=> $result['TELEPHONENO'],
"subsidiary"=> ["id"=> "2"],
"terms"=> ["externalId"=> "PTTRM".$result["TERMID"]],
"vatRegNumber"=> $result['ABN'],
"addressbook" => array(
"items" => array(
array(
"label"=> $address['addr1'],
"addressbookaddress" => $address = array(
"addr1" => $result['ADDRESS1'],
"addressee" => $result['CLIENTNAME'],
"addrText"=> $result['ADDRESS1']."\n".$result['ADDRESS2'],
"externalId" => 'ADDR_'.$netsuiteCustomerId,
);
)
)
)
Adding the externalId to the address doesn't appear to work. We have multiple addresses with the same ID. The SOAP API allows a replaceAll attribute, but that doesn't exist on the REST API.
I haven't tried doing this myself but you may want to check the documentation again (https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSTRW/NSTRW.pdf). It shows samples of replacing sublists using 'replace' in the query parameter.
The REST API browser also mentions 'replace' under request parameters.
You need to use PATCH instead of PUT to update the address
$customer1 = \Stripe\Customer::create([
"description" => "test",
'email' => 'a#example.com',
]);
$customerObj = \Stripe\Customer::retrieve($customer1->id);
$sourceObj = $customer->sources->create(["source" => 'src_xxxx']);
The source object has been created. I can understand this.
I can not understand where in the Customer object the source object was created.
How can I check the source object created above from the Customer object?
var_export($customer->sources->source);
You would have to fetch the Customer object again to see the updated source in the list of sources. Use https://stripe.com/docs/api#retrieve_customer for this
I'm using sequelize for node.js. I define this relationship:
// 1:M - Platform table with Governance status table
dbSchema.Platform_governance.belongsTo(dbSchema.Governance_status, {foreignKey: 'platform_status'});
dbSchema.Governance_status.hasMany(dbSchema.Platform_governance, {foreignKey: 'platform_status'});
So that means I have a table called platform_governance which has a foreign key that points to a governance_status row. A user wants to change this foreign key to point to a different governance_status row.
So I want to first search that this governance_status row the user selected actually exists and is unique, and then make the foreign key point to it. This is what I currently have:
// first I select the platform_governance of which I want to change it's foreign key
dbSchema.Platform_governance.findById(5, {include: [dbSchema.Governance_status]}).then(result => {
// Now I search for the user-requested governance_status
dbSchema.Governance_status.findAll({where:{user_input}}).then(answer => {
// I check that one and only one row was found:
if (answer.length != 1 ) {
console.log('error')
} else {
// Here I want to update the foreign key
// I want and need to do it through the associated model, not the foreign key name
result.set('governance_status', answer[0])
result.save().then(result => console.log(result.get({plain:true}))).catch(err => console.log(err))
}
The result.save() promise returns successfully and the object printed in console is correct, with the new governance_status correctly set. But if I go to the database NOTHING has changed. Nothing was really saved.
Oops just found the problem. When setting associations like this you shouldn't use the set() method. Instead, sequelize creates setters for each association. In my case I had to use setGovernance_status():
// Update corresponding foreign keys
result.setGovernance_status(answer[0])
If anyone finds anywhere in the documentation where this is documented I would appreciate :)
I have the following situation in Yii2:
Project model
CustomField, defining a custom field type and whether it should be applied to Projects (other options are employees and companies)
CustomFieldContent, related to both an entity (project in this case) and a custom field type
So, an example:
Project with id 1
CustomField with id 2
CustomFieldContent with entityId = 1, type = 'project', customFieldId = 2 and value = 'test'
Now, displaying custom content for each project in Yii's gridview is no problem. But, I want to make it searchable and sortable. Therefore, I need to add the custom field name as an attribute to ProjectSearch. That, however, can't be done as Yii doesn't allow for dynamic attributes.
Any ideas as to how to go about this?
For searchable and sortable content i suggest you this tutorial where you can find useful sample for build what you need. ( the scenario nuber 2 is the more appropriate to your needs)
In short term, you should extend your base model adding the relation you need, setup in searchModel proper functions adding to the dataProvider->setSort for the field/relation and add the where condition for filtering.
below a short extract
$dataProvider->setSort([
'attributes' => [
....
'yourRelatedField' => [
'asc' => ['field1' => SORT_ASC, ],
'desc' => ['field1' => SORT_DESC,],
'label' => 'your Laber',
'default' => SORT_ASC
],
]
]);
and extending the where condition for filtering.
/* Add your filtering criteria */
// filter CustomFieldContent
$query->joinWith(['table_a' => function ($q) {
$q->where('table_a.CustomFieldContent LIKE "%' . $this->CustomFieldContent . '%" ');
}]);