I can record a contact from php toolkit, now i should attach contact to an existing opportunity, is this possible with the same way as adding custom field?
$records[0] = new stdclass();$records[0]->FirstName = 'Irish';
$records[0]->LastName = 'Paul';
$records[0]->Phone = '(510) 555-5555';
$records[0]->myCustomField__c= 'value1; value2';
Now to attach this with opportunity, how should i do?
Thank you
Related
I am importing google contacts from a csv file in a specific manner, in the file I have 2 custom fields that need to be added to every contact when they are imported. I have added the first custom field but have no idea how to add a second one programatically. It seems possible as you can add a second custom field from the contact page. Here is the code to add one custom field to the contact:
$opened_file=fopen("export_test.csv", "r");
while(($data = fgetcsv($opened_file, 1000,",")) !== FALSE)
{
$contacts[] = $data;
}
$person = new Google_Service_PeopleService_Person();
$custom_field = new Google_Service_PeopleService_UserDefined();
for($i = 1; $i < count($contacts); $i++)
{
$custom_field->setKey($contacts[$i][50]);
$custom_field->setValue($contacts[$i][51]);
$person->setUserDefined($custom_field);
}
I have tried making a new user defined object, setting the key and value and attaching it to the person but this just overwrites the first custom field. I have also looked this issue up but turned up with nothing. Is it possible to add a second custom field programatically?
UserDefined is a list in the documentation https://developers.google.com/people/api/rest/v1/people#resource:-person.
I'm unsure about the PHP syntax, but based on examples in https://github.com/googleapis/google-api-php-client, try doing
$custom_field_array = array();
...
$person->setUserDefined($custom_field_array);
I cannot figure out how to create a new contact group and assign it to the contact using google people api in php. An error
"person.memberships is a read only field."
occurs at $person->setMemberships():
$contactGroup=new Google_Service_PeopleService_ContactGroup();
//$contactGroup->setGroupType('USER_CONTACT_GROUP');
$contactGroup->setName('Some group');
$contactGroup->create();
$cgm=new Google_Service_PeopleService_ContactGroupMembership();
$cgm->setContactGroupId('groupID');
$membership=new Google_Service_PeopleService_Membership();
$membership->setContactGroupMembership($cgm);
$person=new Google_Service_PeopleService_Person();
$groupMemberships=array(($membership));
$person->setMemberships(array($groupMemberships));//error happens here
Anyone could help with a proper example of creating contact group and assigning it to the contact?
The following code assumes you have instantiated a Google_Client object, and have already created a person and know their ID.
Resource ID example,
$person_id = 'people/1234567890abcde';
Create a contact group,
$peopleService = new Google_Service_PeopleService($client);
$newContactGroup = new Google_Service_PeopleService_ContactGroup;
$newContactGroup->setName('New contact group');
$createContactGroupRequest = new Google_Service_PeopleService_CreateContactGroupRequest;
$createContactGroupRequest->setContactGroup($newContactGroup);
$contactGroup = $peopleService->contactGroups->create($createContactGroupRequest);
$contact_group_id = $contactGroup->getResourceName();
Add a person to contact group,
$peopleService = new Google_Service_PeopleService($googleClient);
$modifyContactGroupMembersRequest = new Google_Service_PeopleService_ModifyContactGroupMembersRequest;
$modifyContactGroupMembersRequest->setResourceNamesToAdd($person_id);
$peopleService->contactGroups_members->modify($contact_group_id, $modifyContactGroupMembersRequest);
You can't set members of the contact group in the creation call. You need to create the contact group in one call, then in a second call add it using members.modify api call.
Using the latest NetSuite PHP Toolkit v2012_2, how can I get the contents of lists and in particular custom lists?
For example, we have a custom list with options for how the customer heard about us. We modify this list from time to time. When a visitor to our site gets to our registration screen we’d like to pull in from NetSuite the list items for the custom list with id 3 (along with each list item’s id) so we can fill a drop-down box for use when creating a contact in NetSuite. This way we can maintain a single list in NetSuite and it will always be current in the website.
Credit and thanks to Saqib!
For reference, here is an example of the code that is now working:
$service = new NetSuiteService();
$service->setSearchPreferences(false, 20);
$recordRef = new RecordRef();
$recordRef->internalId = 1;
$searchField = new SearchMultiSelectField();
$searchField->operator = "anyOf";
$searchField->searchValue = $recordRef;
$search = new CustomListSearchBasic();
$search->internalId = $searchField;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
var_dump($searchResponse);
die();
Perhaps http://tellsaqib.github.com/NSPHP-Doc/ could help you in coding it yourself.
How to implement two type of registration like student and teacher?
I need two type of registration one for Teacher and one for Student. Both are different registration and both have different roles. Is it possible in Drupal? And also I need registering Student there is no admin approval but for Teacher registration, admin approval is required. How can I achieve this in Drupal 6?
In the custom user registration form add one more select box field with ROLE TYPE (student, teacher).Then on the submit hook check like shown below.
function add_student_form_submit($form, &$form_state) {
$fields = array();
$fields['is_new'] = true;
$fields['name'] = $form_state['values']['user_name'];
$fields['pass'] = $form_state['values']['pass'];
$role_type = $form_state['values']['role_type'];
//Add the user to the corresponding role
$fields['roles'] = array($role_type)
//here you can achieve the thing which you want.If the role is a teacher then set
//status = 0, else status = 1
if($role_type == 'student')
$fields['status'] = 1;
else
$fields['status'] = 0; // $user = user_save(drupal_anonymous_user(), $fields); //This works in D7
$user = user_save('', $fields); //pretty sure this is what works in D6 }
If the user is the teacher you should go to http://localhost/domain_name/admin/user/user. Here you can filter the Inactive users and activate them.
hey you can use below modules for creating multilevel registration.
http://drupal.org/project/content_profile
http://drupal.org/project/autoassignrole
above modules help you to create multilevel registration form in site. from content profile you can create form and also give auto assign role to student.
As far as i'm aware, drupal doesn't provide any mechanism for having multiple types of registration forms. However you can fairly easily create your own registration form from scratch. All you really need is the user_save function to create a new user. See the sample code below as part of a form_submit hook
function add_student_form_submit($form, &$form_state) {
$fields = array();
$fields['is_new'] = true;
$fields['name'] = $form_state['values']['user_name'];
$fields['pass'] = $form_state['values']['pass'];
$fields['status'] = 1;
// $user = user_save(drupal_anonymous_user(), $fields); //This works in D7
$user = user_save('', $fields); //pretty sure this is what works in D6
}
Using this you can create whatever custom logic you want for each form
I am building an application with codeigniter that involves adding a "carer" with multiple telephone numbers to a database. From the UI side of things, there is an add button next to each telephone field that uses some javascript magic to clone itself in order for the user to input another number. When the form is submitted, the telephone numbers are submitted as an array.
I have two models setup: carer and carer_telephone. Each model has it's own respective table.
I have been racking my brains for a way that I can get datamapper to validate all the relations before saving them. For example at the moment, only the validation errors for the carer fields are displayed, none for the carer_telephone fields.
Also, I'm not sure if this is the most memory efficient way of dealing with this i.e. creating a new carer_telephone object for every number.
This must be a common setup for many applications but I can't seem to find any documentation on the subject. I am looking for the most standard way of doing this with regards to DataMapper.
The controller so far
function add() {
//Create carer object
$c = new carer();
//Create carer telephone object
$t = new carer_telephone();
//Form submitted
if($this->input->post('add_carer')) {
//Set carer data
$c->title = $this->input->post('title');
$c->first_name = $this->input->post('first_name');
$c->family_name = $this->input->post('family_name');
$c->display_name = $this->input->post('display_name');
$c->date_of_birth = $this->input->post('date_of_birth');
$c->email_address = $this->input->post('email_address');
$c->street_address = $this->input->post('street_address');
$c->town = $this->input->post('town');
$c->county = $this->input->post('county');
$c->postcode = $this->input->post('postcode');
//Set and save telephones
foreach($this->input->post('telephone') as $tel) {
$t = new carer_telephone();
$t->type = 'test';
$t->number = $tel;
$c->save($t);
}
}
//Store carer object
$this->_data['content']['carer'] = $c;
//Load view
$this->load->view('carers/add',$this->_data);
}
Any help on this would be greatly appreciated. Even just a link to an example where somebody has worked on this situation.
Best regards,
Dan
There is an array extension that comes with DataMapper which might be of use to you: http://datamapper.wanwizard.eu/pages/extensions/array.html - lets you save array data to a database, etc.