Use Microsoft Dynamics CRM web service to get customized option set values - soap

The CRM has some customized option sets, for example, Salutation option set is defined for Contact entity. I need to get values of this option set when creating or updating contacts. I tried to use RetrieveOptionSet request to get the option set values as below:
SOAP action to use http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute
SOAP request body
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request i:type="a:RetrieveOptionSetRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<b:key>MetadataId</b:key>
<b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>RetrieveAsIfPublished</b:key>
<b:value i:type="c:boolean" xmlns:c="http://www.w3.org/2001/XMLSchema">true</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>Name</b:key>
<b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">my_type</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true" />
<a:RequestName>RetrieveOptionSet</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
The problem is that I can only use this request to get global option sets, but for customized option sets, this request just returns a not found error.
Does anyone knows how to get customized option set values?
EDIT: I'm using Java client to access Dynamics CRM web service. This is the final SOAP request body I used to successfully get option set values.
<s:Envelope>
<s:Body>
<Execute>
<request i:type="a:RetrieveAttributeRequest">
<a:Parameters>
<a:KeyValuePairOfstringanyType>
<b:key>MetadataId</b:key>
<b:value i:type="c:guid">00000000-0000-0000-0000-000000000000</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>RetrieveAsIfPublished</b:key>
<b:value i:type="c:boolean">true</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>EntityLogicalName</b:key>
<b:value i:type="c:string">contact</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>LogicalName</b:key>
<b:value i:type="c:string">my_type</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true"/>
<a:RequestName>RetrieveAttribute</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
The sample code in this page gave me useful information.

You need to use the RetrieveAttributeRequest, not the RetrieveOptionSetRequest.
The metadata for non-global(local) optionsets are defined as a part of the attribute on the entity itself, rather than as an entirely different structure. ie. if you delete your local optionset attribute from your entity, you lose all of the entire option set definition. But if it's a global optionset, deleting an attribute on a entity the references doesn't result in any loss of data for the option set

I think your question was answered a couple of months ago in this link:
Dynamics CRM - Accessing Custom Product Option Value
Please let me know if it is not the same, and we will try to find another way ;)
But thinking about you requirement again, and if I have understand it properly, how often is that option set going to change? Why don't you just retrieve the optionsets with the crmsvcutil.exe from the SDK?
Cheers,
Mario

Related

Same XACML request different response when I use wso2is and Java application

Hi I’m having problem understand why I get different response when I use the (org.xacmlinfo.xacml.pep.agent.PEPAgent.java) and the tryit function in WSO2IS 5.0.0. They are querying the same policy.
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="OfficeHours" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides" Version="1.0">
<Description>denyOutsideOfficeHours</Description>
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="PermitInOfficeHours">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:2.0:function:time-in-range">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">12:00:00</AttributeValue>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">17:00:00</AttributeValue>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:time-one-and-only">
<AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" DataType="http://www.w3.org/2001/XMLSchema#time"></AttributeDesignator>
</Apply>
</Apply>
</Condition>
</Rule>
</Policy>
PEPAgent
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" IncludeInResult="false"><AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
</Attribute>
</Attributes>
</Request>
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result>
<Decision>Indeterminate</Decision><Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:processing-error"/>
<StatusMessage>urn:oasis:names:tc:xacml:1.0:function:time-one-and-only expects a bag that contains a single element, got a bag with 0 elements</StatusMessage>
</Status>
</Result>
</Response>
Tryit
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:environment-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">foo.com</AttributeValue>
</Attribute></Attributes></Request>
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result><Decision>Permit</Decision><Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status><PolicyIdentifierList>
<PolicyIdReference>OfficeHours</PolicyIdReference>
</PolicyIdentifierList>
</Result>
</Response>
First of all here are a few comments regarding your policy and rule:
the policy description doesn't match the rule description. In one case you say deny, in the other you say Permit.
you use a Condition where in fact a Target would be enough.
Now, as for the different responses: in one case your code (PEPAgent) doesn't send the current time value and the server (is that the PDP?) doesn't add the time either. In the second case, the Tryit client still doesn't send time but obviously the receiving end (another PDP?) fills in the missing time value.
If you look more closely at your first response, you will notice the following error message:
<StatusMessage>urn:oasis:names:tc:xacml:1.0:function:time-one-and-only expects a bag that contains a single element, got a bag with 0 elements</StatusMessage>
This means that you didn't pass in any value for current-time.
I tested this using the Axiomatics Policy Server and I received the expected behavior.

Unable to Add/Modify Mobile Phone field using IPP against QuickBooks desktop

I can't seem to modify or add the Mobile phone field in QuickBooks for QB Desktop. Online works fine, no dice in desktop but according to the XML response of the MOD request it seems to be working fine.
It shows the field being created/modified (idDomain is created, id value generated) however SyncManager never pushes the changes to QuickBooks.
I can modify the Mobile value on the QB side and I'll be able to see that change in my IPP application but no go when heading the other direction.
Here's the XML traces:
http://pastebin.com/qprwAh9z
Any ideas?
I was able to replicate this. The mobile phone number does not sync to the QB desktop file.Seems like a bug.
Please submit a support ticket here:
Link - http://developer.intuit.com/Support/Incident
It looks like, the problem is when you use 'Mobile' in the Phone's 'Tag' field.
Instead of 'Mobile', I tried 'Home' in the Tag field. As an alternate solution you can try the following (I will take a look if there is any constraint in the intermediate QBXML/QBSDK side )
IDS Req
<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="22f39648c5ab1111988854e808163dc9" xmlns="http://www.intuit.com/sb/cdm/v2">
<ExternalRealmId>657117515</ExternalRealmId>
<Object xsi:type="Customer">
<TypeOf>Person</TypeOf>
<Name>SampleCust-IDS12</Name>
<Address>
...
</Address>
<Address>
...
</Address>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>0123456789</FreeFormNumber>
<Default>1</Default>
<Tag>Business</Tag>
</Phone>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>1234567890</FreeFormNumber>
<Default>0</Default>
<Tag>Home</Tag>
</Phone>
...
</Object>
</Add>
Create Response
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="22f39648c5ab1111988854e808163dc9">
<PartyRoleRef>
<Id idDomain="NG">1221097</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-07-19T11:25:43Z</LastUpdatedTime>
<PartyReferenceId idDomain="NG">1261065</PartyReferenceId>
</PartyRoleRef>
<RequestName>CustomerAdd</RequestName>
<ProcessedTime>2013-07-19T11:25:43Z</ProcessedTime>
</Success>
</RestResponse>
QBXML [ 2nd phone no is coming under AltPhone tag ]
<?qbxml version="9.0" ?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError" newMessageSetID="13ff6ae6e2c76b59e49">
<CustomerAddRq requestID="EsbKeyMapHeader:1221097:0">
<CustomerAdd>
<Name>SampleCust-IDS12</Name>
..
<BillAddress>
...
</BillAddress>
<ShipAddress>
...
</ShipAddress>
<PrintAs>SampleCust</PrintAs>
<Phone>0123456789</Phone>
<AltPhone>1234567890</AltPhone>
<Fax></Fax>
..
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>
QB's view [ There is no specific field for Mobile. Mobile/LandLine is kindOf Metadata. I'll check and confirm this behaviour ]
Thanks

cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")

Attempting to hit the Customers end point and the API keeps rejecting my request with this extremely nondescript error:
<ErrorCode>-3002</ErrorCode>
<ErrorDesc>cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")</ErrorDesc>
<DBErrorCode>01400</DBErrorCode>
Here is the sample XML:
<?xml version='1.0' encoding='utf-8' ?>
<Add RequestId='47e1633341s4521a24e269ad12ab3f6' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.intuit.com/sb/cdm/v2'>
<ExternalRealmId>111111111</ExternalRealmId>
<Object xsi:type='Customer'>
<TypeOf>Organization</TypeOf>
<Name>SampleCustomer</Name>
<Address>
<Line1>123 E. Fake St</Line1>
<Line2>Suite 1</Line2>
<City>Somewhere</City>
<Country>USA</Country>
<CountrySubDivisionCode>FL</CountrySubDivisionCode>
<PostalCode>12345</PostalCode>
<Default>true</Default>
<Tag>Billing</Tag>
</Address>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>123-456-4563</FreeFormNumber>
<Default>true</Default>
<Tag>Main</Tag>
</Phone>
<DBAName>Sample Customer</DBAName>
<AcctNum>51f2ce86134c03000a000155</AcctNum>
</Object>
</Add>
Any suggestions? These exceptions are super confusion. I found the one related to "ESB"."PHONE_API"."LABEL_NAME_MAP" was related to an empty phone number field. That isn't the case with this request.
You edited your post to reflect a correct tag, so this answer may no longer be relevant
My first guess would be that, per the documentation, the Address/Tag node allowable values are defined by the PhysicalAddressLabelType enum.
Tag - String - Tag (or label) that identifies the use of the address. The
values allowed are defined in the PhysicalAddressLabelType.
If you look at the allowable values, you'll see the only allowable values are:
Billing
Shipping
But you specified:
Office
Can you try specifying a valid value?
Likewise, you're specifying an invalid Tag for the Phone node as well. The allowable values are here:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/062_enumerations/telephonenumberlabeltype
But you've specified:
Main
Can you try specifying a valid value?

Objects are missing in WADL

I have a web application using Jersey, and I would like to describe its' REST API with WADL.
Jersey generates .wadl file by default, but it does not contain objects (some of my REST calls send/return objects). Actually, I get something like this:
<method id="save" name="POST">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
How can I create .wadl that describes also objects?
Acceptable and returned types are described by XML Schema only when you are accepting/returning application/xml type. There is no generally accepted description of JSON types or structures, so WADL generated from Jersey doesn't contain related description (simply because there is no standard way how to achieve that).

what is the metadata attribute pair in MQFTE ? Why is it used?

I am working with wmqfte. While creating a transfer there is a parameter for metadata attribute pair. Why is this used for ?
One of the FTE engagements I worked on required email notifications of transfer status. Our approach to this was to add an email step in the transfer and the way we passed in the source and destination addresses was with metadata pairs. The transfer XML is provided below for an example:
<?xml version="1.0" encoding="UTF-8"?><request version="4.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FileTransfer.xsd">
<!DOCTYPE request>
<managedTransfer>
<originator>
<hostName>host.example.com</hostName>
<userID>me</userID>
</originator>
<sourceAgent QMgr="QMGR01" agent="AGENT01"/>
<destinationAgent QMgr="QMGR02" agent="AGENT02"/>
<transferSet priority="5">
<metaDataSet>
<metaData key="email.from">fteadmin#example.com</metaData>
<metaData key="email.to">"dept#example.com</metaData>
</metaDataSet>
<item checksumMethod="MD5" mode="binary">
<source disposition="delete" recursive="false">
<file>/root/path/file</file>
</source>
<destination exist="overwrite" type="directory">
<file>/root/path/</file>
</destination>
</item>
</transferSet>
<job>
<name>Your Job Name Here</name>
</job>
</managedTransfer>
</request>
A better way of sending status emails is to watch the transfer notifications published at the Coordination QMgr. However this example does show one possible use for the metadata pairs.