Reputation: 1
Within an Importform template, how can set the mapping to differentiate between inserting a contactmethod record vs updating an existing one?
Upvotes: 0
Views: 27
Reputation: 2247
In QBO3, ContactMethod can be used to track phone numbers, email address, websites or social networking links associated with a contact.
Use case 1: create a new contact with a phone number:
Contact/Save?FirstName=John&LastName=Doe&Phone=888.555.1212
Use case 2: Updated a contact, changing the phone number:
Contact/Save?ID=X&Phone=888.555.2323
Note in this case, you are replacing the phone number with a new phone number; you are not adding an 'extra' phone number.
Use case 3: Add an extra phone number
Contact/Save?ID=X&Methods_0_ContactValue=888.555.2323
Use case 4: Use a Task (ImportForm) to set Title.TitleHeldBy's phone number
This assumes you have a task bound to a Title record, and as part of the task, you wish to set the phone number of the contact linked to from the Title.TitleHeldBy field.
Create an Question for the task named as follows:
Title_TitleHeldBy_Phone
which will in turn call:
ImportForm/Save?ID=X&Title_TitleHeldBy_Phone=Y
Use case 5: Use a Task (ImportForm) to add extra phone numbers for a TitleHeldBy contact
Create an Question for the task named as follows:
Title_TitleHeldBy_Methods_0_ContactValue
which will in turn call:
ImportForm/Save?ID=X&Title_TitleHeldBy_Methods_ContactValue=Y
How this works
When calling Contact/Save, the Contact will map any Phone or Email parameter to the 'primary' ContactMethod with a MethodType matching 'Phone' or 'Email'. This handles 90% of the use cases we encounter: you just want to update the phone number for a contact.
Note that 'Phone' and 'Email' are configured values. You can add in additional such method types from Design > Configuration > Modules > ContactMethod > MethodTypes. For example, if you add a new MethodType called 'LinkedInProfile', you could then call:
Contact/Save?ID=X&LinkedInProfile=Y
and that will insert a LinkedInProfile ContactMethod if one did not exist, or update it if it already exists.
The example of an ImportForm saving the phone number of a Title.TitleHeldBy contact works in a similar manner:
ImportForm/Save
will recognize any fields that match it's parent table ('Title' in this example), passing all such fields to Title/Save
Title/Save
will recognize any foreign key fields, such as TitleHeldBy, and pass all such fields to the appropriate {Class}/Save
method (in this case, Contact/Save
since TitleHeldBy is a foreign key to a Contact).ImportForm/Save
calls Title/Save
with all Title* fields, which in turn calls Contact/Save
with all TitleHeldBy fields.Upvotes: 0