Hello everyone I have rather interesting problem (at least for me) I have an REST endpoints which sends me data that looks like this
{
"user": {
"name": "demo",
"phones": [
"iPhone",
"Samsung"
],
"address": "address"
}
}
I have a corresponding java model (User has a list of group etc. really simple)
The task is to send this data to salesforce using apache-camel while migrating single Entity (user) is quite simple and comes down to
from("direct:start")
.setHeader("Authorization", constant("Basic a2tkYl9zZnJlYWQ6a2tkYl9zZjg2NQ=="))
.to(MY_SOURCE)
.bean(UserProcessor.class, "process")
.to(SALESFORCE);
I can't figure out how to associate groups with user, since they are connceted through ID fields ( phone has user_id property ) which don't exist yet obviously because the migration process is still ongoing. Is there any way that I can migrate both things simultaneously?
If you want to create different SF Object records and link them together then first create the parents and then use the Id from the parents to create the child records.
You can create the records without the Salesforce Id and link them together only if you have an external Id that can link the two records.
For the grouping you will need to do separate calls or build a API that can receive your data and properly insert or upsert in Salesforce.
Refer to documentation for more:
https://developer.salesforce.com/page/Salesforce_APIs
https://help.salesforce.com/articleView?id=000002783&type=1
Related
I have two objects - "Account" and "Appointment". I'm trying to pull the value of the field "Status" from the "Appointment" object where "Account.Initial_Date" matches "Appointment.Date_Time". I initially tried making a new field in the "Account" object to return a text field and see if maybe it would return the first value:
Appointment__c.Status__c
Which results in the error:
"Field Appointment__c does not exist. Check spelling."
I was told that it's too difficult to link from "Appointment" to "Account" because there can be multiple appointments per account, which is why I'm trying to link based on the date fields. My next attempt was using VLOOKUP, but I read that this only works between custom objects, and I think I'm working with standard objects here... what kind of solution should I be looking for?
Adding the tag apex here in case this can only be achieved via a script of some sort - if that's the case, I'll make attempt via that.
I was told that it's too difficult to link from "Appointment" to "Account" because there can be multiple appointments per account
This is incorrect. That relationship appears to be exactly the same as that between Contact and Account - one Contact, many Accounts. It's a very common relationship pattern in Salesforce.
If an Appointment is logically related to an Account, it should have a relationship field referencing the Account object to which it is related.
However, having a one-to-many relationship does not mean you can trivially represent specific data points from the many side to the one side. The native tool to do so is the Roll-Up Summary Field, but it does not apply to your use case.
There's really three ways to implement your objective, which is essentially implementing a variant of a roll-up summary. VLOOKUP(), which works only in Validation Rules, does not apply here.
Write two Apex triggers (one on Account and one on Appointment) to react to all changes that would influence what value should appear in the Account__c.Status__c field.
Write equivalent Process and Flow declarative automation, which cannot get 100% of the way there because Process Builder and Flow cannot react to delete events.
Use the free and open source Declarative Lookup Rollup Summaries application to define a roll-up summary. DLRS can populate a field from the child object (Appointment) to the parent (Account) based on a sorting by another field (Date_Time__c).
I'm not familiar with SOQL or Salesforce configuration but I've been asked to come up with a tool to easily import files as attachments to objects.
I'm using the Developer Console in Salesforce to figure this out. I found that the attached files are a custom object type named "File_Manager_File__c". This object contains several fields such as "File_Name__c", "Id" and most pertinently "Parent_ID__c". However "Parent_ID__c" is Apex Type: string so as far as I can tell it's not an actual child relationship (as my limited Salesforce understanding goes). Another field, "Parent_Object_name__c" is Apex Type: string and returns other objects that I would expect to have files attached (eg. "Job", "Contract", "Opportunity")
Since there doesn't seem to be an actual relationship is there still a way to join in SOQL this Object and objects that can have files attached to them such as "Order" (which has "ID" as a field)?
It sounds like someone has done a clumsy reimplementation of the out-of-the-box Content-based attachments feature in Salesforce. The use of text fields is because Salesforce does not allow custom polymorphic relationships, like LinkedEntityId on the native ContentDocumentLink junction object.
There's no way to perform a join in SOQL without a defined relationship in the schema. These records presumably could be imported using a tool like Data Loader by populating Parent_ID__c and Parent_Object_name__c directly with values like 001000000000001 and Account, but you won't be able to query those records without performing the join synthetically in Apex or whatever language an external client is written in.
you can import theses data in database for example Postgresql.Only create the tables in the postgresql and import the data. So you can make any query.
What is the simplest way to quickly create edges in ArangoDB programmatically?
I would like to create relationships between documents based on a common attribute. I'd like to be able to select an attribute, and for every document in collection A, create an edge to every document in collection B that has the same value in an equivalent attribute.
For example, if I've imported email messages into a collection and people into another collection, I would like to generate edges between the emails and collections. An email's schema might look like this:
{
"_key":
"subject":
"body":
"from":
"to":
}
And a person's schema might look like this:
{
"_key":
"name":
"email":
}
Let's say that the values in the from and to fields in the email messages correspond to email addresses that we may find in the people collection.
I'd like to be able to take the collections, attributes, and edge parameters as input, then, for every document in the people collection, create an edge to every document in the email collection that has the same email address in the from attribute as the current document's email attribute.
So far, I think that Foxx may be the best tool for this, but I am a bit overwhelmed by the documentation.
Eventually, I'd like to create a full CRUD based on shared attributes between documents defining edges, including an "upsert" equivalent- updating an edge if it already exists and creating it if it doesn't.
I know that doing this with individual API calls with the standard HTTP API would be far too slow, since I would need to query Arango for every document in a collection and return very large numbers of results.
Is there already a Foxx service that does this? If not, where should I start to create one?
A single AQL query should suffice:
FOR p IN people
FOR e IN emails
FILTER p.email == e.from
INSERT {_from: p._id, _to: e._id} INTO sent
The email addresses in the vertex collection people are matched with the from email addresses of the emails vertex collection. For every match, a new edge is inserted into an edge collection sent, linking people and email records.
If both vertex collections contain a small number of documents, it is okay to execute this query without indexes (e.g. 1,000 persons and 3,000 emails took about 2 seconds in my test). For larger datasets, make sure to create a hash index in people on the email attribute, and in emails a hash index on from. It reduced the execution time to about 30ms in my test.
I have started working with spring and mongodb few months ago. Till now I din't get how to fetch data from multiple collection using Mongotemplate or MongoRepository. I have two collections Person and Contacts.now I want to fetch list of Customer along with Contacts. Customer is having the is is _id and Contact is having the relation id is customerId So how can i get the customer contact details of the data.
Your data needs de-normalization, think the MongoDB way. You need to store 'Person/Customer' data along-with corresponding 'Contacts'. This is a 1:n kind of association. You can easily store required data in the following schema , below is a sample 'Person/Customer' document which embeds his 'Contact' details=>
{
name:"abc",
age: 35,
Contact:{[email:"abc1#gmail.com",mobile:123],[email:"abc2#gmail.com",mobile:234]}
}
If you end up normalizing data like mentioned, you tend to throw away the powerful embedding capability that MongoDB offers and end up doing joins in code.
Trying to model some highly connected, but also hierarchical data in app engine.
Here is an example:
Person:
Phone Numbers:
Number: 555-555-5555, Ext: 123, Notes: Work
Number: 444-444-4444, Ext: 456, Notes: Mobile
One entity, contained data structures stored as JSON blobs:
One way to do this would be to store the phone_numbers collection as an unindexed blob of JSON text, and then add a search property so that a person could be queried by phone number:
p_entity = Person()
p_entity.phone_numbers = dbText(simplejson.dumps([{'Number':'555-555-5555', 'Ext':'123', 'Notes':'Work'},{'Number':'444-444-4444', Ext:'456', Notes:'Mobile'}]))
p_entity.phone_numbers_search_property = ['5555555555', '4444444444']
p_entity.put()
Multiple entities with parent-child relationships:
Another way would be to use child and parent entities:
person_entity = Person()
person_entity.put()
phone_entity1 = PhoneNumber(parent=person_entity)
phone_entity.Number = '5555555555'
phone_entity.Ext = '123'
phone_entity.Notes = 'Work'
phone_entity2 = PhoneNumber(parent=person_entity)
phone_entity.Number = '4444444444'
phone_entity.Ext = '456'
phone_entity.Notes = 'Mobile'
A use case:
This is highly connected data. A person object contains multiple phone numbers. But phone calls can also be made to and from those phone numbers. Records of phone calls will also need to refer to these phone numbers.
The purpose of parent-child entity relationships:
After reading over the documentation, I was under the impression that the purpose of parent-child entity relationships was for performing transactions.
However, could they also be appropriate in this case? Is it almost as efficient to pull a parent and all of it's children out of the datastore as to pull one entity out with its "children" instead stored as JSON text blobs?
Basic question
Is there a normal and accepted way to handle this kind of data in google app engine?
Take a look at the new NDB API (in particular the StructuredProperty: http://code.google.com/appengine/docs/python/ndb/properties.html#structured)
Also, from my experience and what I've read, when you update an existing entity, you do not pay for writes on properties that did not change, that is, in contrast to what Riley said, you would only pay for writing the object + 2 writes for any indexed properties that were modified + 1 write for each composite index you have that contains the model and properties you modified.
From all the articles I've read and my experience (I too had to come up with a solution for this and ended up with the JSON method) you want to pack as much as you can into a single entity to minimize trips to the datastore which cost the most in terms of $$ and time.
There's no special bonus for pulling children entities out of the datastore. If you get two entities, the cost is the same whether they're in the same entity group or not. The only purpose of entity groups in app engine is transactions.
Should your records of phone calls change when the phone number is changed? My initial thought is that the records should have a separate copy of the phone number data, not a reference to a phone number object. You can still query the call log by phone number. It makes more sense to store a reference to the contacts involved, so that if their name changes or something the call log can be updated.