Sugar SOAP set_entry - php

I am trying to add entries to a Sugar Contacts database with the following SOAP code in PHP.
$set_entry_params = array(
'session' => $result_array->id,
'module_name' => 'Contacts',
'name_value_list'=>array(
array('name'=>'Name','value'=>'Brian')
)
);
$result = $soapClient->__soapCall('set_entry', $set_entry_params);
An entry is made in the sugar db, but the name field is left blank and the Role field is labelled: Pre Sugar Roll Out
does anyone know what is wrong here?

The issue is probably due to using "Name" as your "name" in teh "name_value_list". The "Name" field is just a concactonation of the "first_name" and "last_name" fields. Try:
$set_entry_params = array(
'session' => $result_array->id,
'module_name' => 'Contacts',
'name_value_list'=>array(
array('name'=>'first_name','value'=>'Brian')
)
);
$result = $soapClient->__soapCall('set_entry', $set_entry_params);

Related

Fill custom CRM fields in Bitrix via REST API

I have the need to fill custom fields in Bitrix24 CRM via REST API.
When it comes to working on standard fields (like TITLE, TEL, etc) it works, but if I try to valorize a custom field by putting it's property name in the request the endpoint simply ignores it.
Here you have a snippet:
$company = CRest::call(
'crm.company.add',
[
'fields' => [
"TITLE" => "Company 1"
, "COMPANY_TYPE" => "Customer"
, "CURRENCY_ID" => 'EUR'
, "REVENUE" => "123000"
, "ADDRESS" => "st. some address"
, "ADDRESS_CITY" => "some city"
, "ADDRESS_POSTAL_CODE" => "12345"
, "ADDRESS_PROVINCE" => "some province"
, "PHONE" => [
["VALUE" => "1230000000", "VALUE_TYPE" => "WORK"]
,["VALUE" => "1234000000", "VALUE_TYPE" => "FAX"]
]
, "EMAIL" => [ ["VALUE" => "me#company1.com", "VALUE_TYPE" => "WORK"] ]
, "INDUSTRY" => "MANUFACTURING"
, "CUSTOM_FIELD" => "Hey I'm not a standard field and I'm going to be ignored"
]
]
);
Did anyone have the same need? How can I solve it?
I found the solution.
Simply write the Field ID instead of the Field Name. The Field ID looks like "UF_CRM_5AERER454DD4". By putting this as key and the value after " => " the property gets valorized.

DocuSign REST API (PHP) - pre-fill custom tags

I am working on project in which I need to use DocuSign API (PHP). This is my first experience with DocuSign and I successfully made template in DocuSign Console with roleName = signer. There I also made Custom Text Tags: address, city, state and phone and drag them to the desired location in my template. I want there to put my customer (signer) information from project database.
From my project I successfully made connection with DocuSign via PHP API and receive Embedded Singing View URL which opens my template where the user can sign document without problem.
But... all my custom text tags are empty and signer can type into them. I need to pre-fill them with signer personal data which is coming from database. I triple check custom tag label spelling, upper/lower case in my DocuSign Console and in my code as well as roleName->tagLabel relation. My PHP code is below.
Can someone, please, tell me what I am doing wrong?
I lost two days on it.
$data = array(
"accountId" => $accountId,
"emailSubject" => $this->_emailSubject,
"templateId" => $templateId,
"templateRoles" => array(
array(
"email" => $email,
"name" => $recipientName,
"clientUserId" => $clientUserId,
"roleName" => "signer",
"customFields" => array(
"textCustomFields" => array (
array (
"name" => "address",
"value" => "Address from DB",
"show" => "true",
),
array (
"name" => "city",
"value" => "City from DB",
"show" => "true",
),
array (
"name" => "state",
"value" => "State from DB",
"show" => "true",
),
array (
"name" => "phone",
"value" => "Phone from DB",
"show" => "true",
),
),
),
),
),
"status" => "sent"
);
You need to use the textTabs type in your JSON, not customFields which is used for something else. For instance, if you drag a Data Field from the UI onto the document and give it name address, to pre-fill that field you would need to reference it's tabLabel and value fields like this:
"roleName" => "signer",
"tabs" => array(
"textTabs" => array(
array(
"tabLabel"=> "address",
"value" => "123 Main St."
)
)
)

Magento Soap API Add Bundle Product to Cart

I'm trying to create an order with Magento SOAP API v1 and having issue when adding bundled products to the cart. I'm able to get an order through correctly with simple products but I'm confused about adding bundled products.
// The Products Array with Bundle
$products = array(
array(
"product_id" => "38914",
"qty" => "1",
"bundle_option" => array(
"18194" => "20360",
),
"related_product" => null,
"bundle_qty" => array("20360" => "1"),
"options" => array(
"0" => array(
"key" => "3328",
"value" => "4494",
),
"1" => array(
"key" => "3329",
"value" => null,
),
"2" => array(
"key" => "3339",
"value" => null,
),
)
)
);
// Get an API session
$client = new \SoapClient('magentoinstallation/index.php/api/soap/?wsdl');
$session = $client->login('user', 'password');
//Create the Cart
$cart = $client->call( $session, 'cart.create');
// add the products
$resultCartProductsAdd = $client->call( $session, "cart_product.add", array( $cart, $products ) );
I've tried many different formats and getting errors
Selected required options are not available
Please specify product option(s).
Any assistance or suggestions would be greatly appreciated.
I figured out a way to add a bundle product to cart via SOAP.
The values within the key bundle_option must be the ids of the models for the options (bundle/selection) (not the product ids). The keys must be the id for the option (I assume that's already correct in your example)
$products = array(
array(
"product_id" => "38914",
"qty" => "1",
"bundle_option" => array(
"18194" => "20360", // <-- THE VALUE MUST BE THE ID OF THE CORRESPONDING "bundle/selection" MODEL, INSTEAD OF THE PRODUCT'S ID
),
// ...
);
Also the key for the bundle quantities should be bundle_option_qty instead of bundle_qty.
Propably the availability of the bundled products will disturb your process, so ensure the products are all salable.
I tried it successfully with the sample data of magento and this snippet
$client = new \SoapClient('magentoinstallation/index.php/api/soap/?wsdl');
$session = $client->login('testuser', 'password');
$products = array(
array(
"product_id" => 158,
"qty" => "1",
"bundle_option" => array(
1 => 2, // 1 is the option id, 2 is the bundle/selection id
),
)
);
$cart = $client->call($session, 'cart.create', array('default'));
$resultCartProductsAdd = $client->call($session, "cart_product.add", array($cart, $products));
I retried my answer and found an important point to recognize.
SELECT A STORE ;-)
Just use
$cart = $client->call($session, 'cart.create', array('default'));
instead of
$cart = $client->call($session, 'cart.create');
(for more details please check the API specs: http://www.magentocommerce.com/api/soap/checkout/cart/cart.create.html)
After changing this, it was simple to add any bundle product, how described above

get values form global secondary indexes table

I am using DynamoDB and zend framework.
I am able to fetch row from normal table using this.
$response['Items'] = $this->dbClient->query(
array(
"TableName" => "user",
"KeyConditions" => array(
"userId" => array(
"ComparisonOperator" => ComparisonOperator::EQ,
"AttributeValueList" => array(
array(Type::NUMBER => 2))
)
)
)
);
But How I can fetch information based on Global secondary indexes.
I have two fields in this table Id and email.
I want to search based on email and getting Id from Global secondary index table. And I want to use this id to get user's all other information from main user table. I want to do this in local DynamoDB.
How I can fetch id based on email from Global secondary index table in zend framework?
You just have to add index name while query, but in your global index email should be hash here all the attribute will be projected.
$response = $this->dbClient->query(
array(
"TableName" => "user",
"IndexName" => "index name",
"KeyConditions" => array(
"email" => array(
"ComparisonOperator" => ComparisonOperator::EQ,
"AttributeValueList" => array(
array(Type::STRING => "email#abc.com"))))));
then you can fetch userId

MailChimp API PHP - Add to Interest Group

I'm currently using the MailChimp API for PHP, version 1.3.1 (http://apidocs.mailchimp.com/api/downloads/#php)
I've set up a list in MailChimp, and would like to dynamically add:
Subscribers to the list (done: $objMailChimp->listBatchSubscribe($strMailingListID, ...))
Interest Groupings (done: $objMailChimp->listInterestGroupingAdd($strMailingListID, ...))
Interest Groups into those Groupings (done: $objMailChimp->listInterestGroupAdd($strMailingListID, ...))
Subscribers assigned to relevant Groups (not done)
The API (http://apidocs.mailchimp.com/api/1.3/#listrelated) is somewhat unclear on how to add a subscriber to an interest group - does anyone here have any ideas?
As of version 2.0 of MailChimp's API, this should work:
$merge_vars = array(
'GROUPINGS' => array(
array(
'name' => "GROUP CATEGORY #1", // You can use either 'name' or 'id' to identify the group
'groups' => array("GROUP NAME","GROUP NAME")
),
array(
'name' => "GROUP CATEGORY #2",
'groups' => array("GROUP NAME")
)
)
);
Source: http://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
Using a barebones PHP wrapper (https://github.com/drewm/mailchimp-api/) you can then send this to MailChimp via either the lists/subscribe or lists/batch-subscribe:
$MailChimp = new MailChimp('API_KEY');
$result = $MailChimp->call('lists/subscribe', array(
'id' => 'LIST ID',
'email' => array('email'=>'trevor#example.com'),
'merge_vars' => $merge_vars
));
For MailChimp API v3
As of v3, 'groupings' has changed to 'interests'.
You have to find out the ID of the group (interest) that you are wanting to add to. Unfortunately this cannot be found anywhere on the MailChimp dashboard.
The easiest way to find out the 'interest' ID (rather than creating a script) is to go to the MailChimp playground and then, after entering in your API key, route to...
lists > the list in question > interest-categories (in the sub-resources dropdown)
then...
interests (in the sub-resources dropdown) for interest category
then...
Click through to the interest and refer to the 'id' field, ignoring the other ID fields
OR
lists > the list in question > members (in the sub-resources dropdown)
then...
load (in the actions dropdown) for any member
or
Create Members (button)
The page will load the member's details. Scroll down until you see the 'interests' array/object. There you will see the IDs. Notice they can be set to true or false.
You will have to figure out which ID relates to what 'group'/'interest' by going about the previous method or making the call, and then looking at the member's details via your MailChimp dashboard.
So when it comes to actually making the POST call ('member' create), you would want something on the lines of...
{
"email_address":"example#freddiesjokes.com",
"status":"subscribed",
"interests": {
"b8a9d7cbf6": true,
"5998e44916": false
},
# ADDITIONAL FIELDS, IF REQUIRED...
"merge_fields":{
"FNAME": "foo bar",
"LNAME": "foo bar",
"MERGE3": "foo bar",
"MERGE4": "foo bar"
}
}
A PUT call ('member' edit) example...
{
"interests": {
"b8a9d7cbf6": false,
"5998e44916": true
}
}
It seems that you must declare every 'interest', and state whether it is true or false.
I could not get the other answers on this page to work. Here's the merge vars that I had to use:
$merge_vars = array(
'GROUPINGS' => array(
0 => array(
'id' => "101", //You have to find the number via the API
'groups' => "Interest Name 1, Interest Name 2",
)
)
);
Use GROUPINGS merge var:
Set Interest Groups by Grouping. Each element in this array should be
an array containing the "groups" parameter which contains a comma
delimited list of Interest Groups to add. Commas in Interest Group
names should be escaped with a backslash. ie, "," => "\," and either
an "id" or "name" parameter to specify the Grouping - get from
listInterestGroupings()
Here's the code I got to work
require_once 'MCAPI.class.php';
require_once 'config.inc.php'; //contains apikey
// use this once to find out id of interest group List
//$retval = $api->listInterestGroupings($listId);
//echo '<pre>';
//print_r($retval);
//echo '</pre>';
//die();
$emailAddress = 'info#example.com';
//You have to find the number via the API (id of interest group list)
$interestGroupListId = FILLMEIN;
$api = new MCAPI($apikey);
// Create an array of Interest Groups you want to add the subscriber to.
$mergeVars = array(
'GROUPINGS' => array(
0 => array(
'id' => $interestGroupListId,
'groups' => "FILL IN GROUP NAMES",
)
)
);
// Then use listUpdateMember to add them
$retval = $api->listUpdateMember($listId, $emailAddress, $mergeVars);
if ($api->errorCode){
echo "Unable to update member info!\n";
echo "\tCode=".$api->errorCode."\n";
echo "\tMsg=".$api->errorMessage."\n";
} else {
echo "Returned: ".$retval."\n";
}
This is a variation of Justins answer but having tried all the above this is the only one I could get to work with DrewM's MailChimp wrapper
$merge_vars = array(
'GROUPINGS' => array(
0 => array(
'id' => '[GROUP_LIST_ID]', // need grouping ID
'name' => '[OR_GROUP_LIST_NAME]', // or name instead
'groups' => array( '[GROUP_NAME_1]', '[GROUP_NAME_2]' )
)
),
);
$mc = new MailChimp('[YOUR_MAILCHIMP_API]');
$mc->call(
'lists/subscribe', array(
'id' => '[YOUR_LIST_ID]', // list ID
'email' => array( 'email' => 'someone#something.com'),
'merge_vars' => $merge_vars,
'double_optin' => true,
'update_existing' => true,
'replace_interests' => false, // do you want to add or replace?
'send_welcome' => false,
)
);
If you are unsure of your groups lists ID and wish to use it you can call:
$current_groupings = $mc->call( 'lists/interest-groupings', array(
'id' => '[GROUP_LIST_ID]',
) );
var_dump($current_groupings);
Also please note optional but very important last parameter of listUpdateMember, by default replace_interests it set to true so it will overwrite any subscription the user you are updating could have had in the past. If you want to add new ones not touching previous ones just pass the new group name you wanna add and set replace_interests to false.
$api = new MailChimp('API_KEY');
$pArray = array('GROUPINGS'=>array(
array('name'=>'GROUP CATEGORY', 'groups'=>'group1,group2'),
)
);
if (is_array($pArray)) {
$api->listUpdateMember($pListId, $pEmail, $pArray, '', false);
}
Example using DrewM's MailChimp wrapper and shorthand syntax for arrays (PHP 5.4+) add to groups:
$merge_vars = [
'GROUPINGS' => array(
0 => [
'id' => 12345, // need grouping ID
'name' => 'Interests', // or name instead
'groups' => [ 'cars', 'trucks' ]
]
]
];
$mc = new MailChimp('API_KEY');
$mc->call(
'lists/subscribe', [
'id' => '9876', // list ID
'email' => array[ 'email' => 'example#abc.com' ],
'merge_vars' => $merge_vars,
'double_optin' => true,
'update_existing' => true,
'replace_interests' => false, // do you want to add or replace?
'send_welcome' => false,
]
);
You need grouping 'name' OR 'id', both are not needed. To get grouping ID use: lists/interest-groupings

Categories