FetchXML Localization - dynamics-crm

I have a FetchXML Query that returns the correct entities for my portal.
How do I get the translated values stored in my CRM
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="testentity">
<attribute name="xyz_testclassification" />
<attribute name="xyz_schemaname" />
</entity>
</fetch>

Working with XML and assuming attribute "xyz_testclassification" is an option set type your FetchXML query could return a resultset like this:
<resultset morerecords="0">
<result>
<xyz_testclassification name="Option One" formattedvalue="10003">10003</xyz_testclassification><xyz_schemaname>One</xyz_schemaname>
</result>
<result />
<result>
<xyz_testclassification name="Option Two" formattedvalue="10004">10004</xyz_testclassification><xyz_schemaname>Two</xyz_schemaname>
</result>
<result>
<xyz_testclassification name="Option Three" formattedvalue="10001">10001</xyz_testclassification><xyz_schemaname>Three</xyz_schemaname>
</result>
</resultset>
Here XML attribute "name" contains the display name of the option value. Attribute "formattedvalue" is only useful for numeric attributes (int, decimal, double, money).
When you are using FetchXML in C#, method IOrganizationService.RetrieveMultiple will return Entity objects. The Entity class has a FormattedValues collection containing the display values.
All values are returned according to the language and formatting settings of the user on behalf of whom the system is queried.

I agree with Henk van Boeijen. I'd like to add that if you using the Web Api endpoint it is also possible by adding "Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue" in the header of the request.
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
{
"#odata.context": "[Organization URI]/api/data/v8.2/$metadata#accounts(name,donotpostalmail,accountratingcode,numberofemployees,revenue)",
"value": [
{
"#odata.etag": "W/"502170"",
"name": "Fourth Coffee (sample)",
"donotpostalmail#OData.Community.Display.V1.FormattedValue": "Allow",
"donotpostalmail": false,
"accountratingcode#OData.Community.Display.V1.FormattedValue": "Default Value",
"accountratingcode": 1,
"numberofemployees#OData.Community.Display.V1.FormattedValue": "9,500",
"numberofemployees": 9500,
"revenue#OData.Community.Display.V1.FormattedValue": "$100,000.00",
"revenue": 100000,
"accountid": "89390c24-9c72-e511-80d4-00155d2a68d1",
"transactioncurrencyid_value": "50b6dd7b-f16d-e511-80d0-00155db07cb1" } ]
}
For more details: https://msdn.microsoft.com/en-us/library/gg334767.aspx

Related

WSO2 Payload Factory not working as expected

I am having troubles configuring the Payload Factory to make it work as expected.
I am trying to process the response of a backend service, which is:
<Documents xmlns="http://ws.wso2.org/dataservice">
<Document>
<Data>
{ "_id" : { "$oid" : "5bbce6ec9e0aae7e5c3a150a"} , "Plan" : "XXXX"}
</Data>
</Document>
<Document>
<Data>
{ "_id" : { "$oid" : "5bbce7279e0aae7e5c3a150b"} , "Plan" : "YYYY"}
</Data>
</Document>
</Documents>
I need to extract the json in each Data tag and construct a JSON that looks something like:
{
Data:
{
_id: {...},
Plan: ...
}
}
Just for testing purposes, I was trying to use the Payload Factory Mediator to get all Data tags using XPath. This is the outSequence of my API (again, the response that comes from the backend is just like the one above):
<outSequence>
<payloadFactory media-type="xml">
<format>
<newTestData>$1</newTestData>
</format>
<args>
<arg evaluator="xml" expression="//Data" />
</args>
</payloadFactory>
<log level="full" />
</outSequence>
The problem is that the log shows that the newTestData tag is empty after the Payload Factory process the response message.
The XPath was tested in an XPath Online Tester and it is correct so: what am I doing wrong?

Issues with https and Service Fabric

While trying to implement https on our ServiceFabric backend, following this guide, I found my local cluster throwing following error:
There was an error during CodePackage activation.The service host
terminated with exit code:1
and sometimes the following would pop up:
fabric:/Dev.Project/Api is not ready, 1
partitions remaining. => Something is taking too long, the application
is still not ready.
In the Diagnostic Events I find this
{
"Timestamp": "2018-08-20T12:01:21.6423999+02:00",
"ProviderName": "Microsoft-ServiceFabric",
"Id": 23083,
"Message": "ApplicationHostTerminated: ApplicationId=fabric:/Dev.Project, ServiceName=fabric:/Dev.Project/Api, ServicePackageName=ApiPkg, ServicePackageActivationId=1d4426dc-3d5e-41ea-aa44-6e9794ff7c69, IsExclusive=True, CodePackageName=Code, EntryPointType=Exe, ExeName=Setup.bat, ProcessId=29024, HostId=77c22be7-b993-46c6-92dd-7c7ed0c8af1c, ExitCode=1, UnexpectedTermination=True, StartTime=12:01:21.568939 (151,099.982 MSec). ",
"ProcessId": 25768,
"Level": "Informational",
"Keywords": "0x4000000000000001",
"EventName": "Hosting",
"ActivityID": null,
"RelatedActivityID": null,
"Payload": {
"eventInstanceId": "6dbdc967-85ed-429a-ae6a-939aeeea1e3f",
"applicationName": "fabric:/Dev.Project",
"ServiceName": "fabric:/Dev.Project/Api",
"ServicePackageName": "ApiPkg",
"ServicePackageActivationId": "1d4426dc-3d5e-41ea-aa44-6e9794ff7c69",
"IsExclusive": true,
"CodePackageName": "Code",
"EntryPointType": 1,
"ExeName": "Setup.bat",
"ProcessId": 29024,
"HostId": "77c22be7-b993-46c6-92dd-7c7ed0c8af1c",
"ExitCode": 1,
"UnexpectedTermination": true,
"StartTime": "2018-08-20T12:01:21.5689395+02:00"
}
}
The Id being the Id of my Api-service. It probably has something to do with the Setup.bat that's not being executed correctly, or errors are thrown while running it, but I can't figure out what to do about it. As stated in the guide, I added the
<Principals>
<Users>
<User Name="SetupAdminUser">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
part, and added the RunAsPolicy to the service as well
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="ApiPkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides>
<ConfigOverride Name="Config">
...
</ConfigOverride>
</ConfigOverrides>
<EnvironmentOverrides CodePackageRef="Code">
...
</EnvironmentOverrides>
<Policies>
<RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="Setup" />
</Policies>
</ServiceManifestImport>
I searched all over, but I can't find what the problem is. Any input is welcome!
Thanks in advance!
This works for me.
I have added LocalSystem instead of Admin user.
<Policies>
<RunAsPolicy CodePackageRef="Code" UserRef="SetupLocalSystem" EntryPointType="Setup" />
</Policies>
<Principals>
<Users>
<User Name="SetupLocalSystem" AccountType="LocalSystem" />
</Users>
Also take care of DNS name in SetCertAccess.ps1 file, it should be same as cluster name.
$subject="your cluster DNS name"

How to get the current (logged) user in XML Odoo V11?

I'm working on Employee Directory module in odoo11 and I want to set a notebook page invisible to the current user (Logged user) if he is different to the related user.
I tried to use user.id in XML but it does not work.
Here is my code :
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '!=', user.id)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
The error message :
<class 'NameError'>: "name 'user' is not defined" while evaluating
"{'invisible': [('user_id', '!=', user.id)]}"
None" while parsing /opt/odoo/odoo/my_addons/hr_dz/views/employee_views.xml:5, near
<record id="view_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
Any idea about that, please ?
One of the thing i know to use a field in attrs the field must be Mentionsed in the form. i don't know how to get the value of the user id in the form. but if there is not a short way like uid or user you can work arround this, just create a m2o field to res.users make this field compute field with store = False.
Please try this it useful to you.:
# by default store = False this means the value of this field
# is always computed.
current_user = fields.Many2one('res.users', compute='_get_current_user')
#api.depends()
def _get_current_user(self):
for rec in self:
rec.current_user = self.env.user
# i think this work too so you don't have to loop
self.update({'current_user' : self.env.user.id})
and you can use this field in your form.
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '=', current_user)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
In your case basically, we can achieve directly with uid global expression variable on view level.
uid is also used into the expression evaluation in odoo xml view file
<page name="hr_settings" string="HR Settings" attrs="{'invisible':[('user_id', '!=', uid)]}">
<group>
<group string='Status' name="active_group">
<field name="company_id"/>
<field name="user_id" string="Related User"/>
</group>
</group>
</page>
No need to add and create any compute field for the code.
Please see the following view under the addons of Odoo V11
addons/project/project_view.xml.

How could I properly configure Solr to index my Oracle database?

I've been trying to configure Solr to work with my Oracle 11.2 database as a datasource but nothing works. I have thoroughly explored the documentations and it seems to lack a good and working guide.
For a simple scenario, I want to index my single table [topic]
The structure of my table topic is shown below:
ID (autonumber)
Topic (varchar 50) I want to index this
Info (varchar 255) I want to index this
My solr configurations (so far)
I have added a new collection for this Oracle, name it "oracle_test". So I configure the folder structure as guided by the official documentation for this collection as follows:
~/solr/server/solr/
oracle_test
conf
data-config.xml
elevate.xml
schema.xml
solrconfig.xml
data-config.xml
I have configured a working datasource connection string to my Oracle, specified the query to my topic table, also the fields I want Solr to look up.
<dataConfig>
<dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:system#//127.0.0.1:1521/orcl/" user="system" password="*****"/>
<document>
<entity name="help" query="select \"topic\",\"info\" from \"topic\"" dataSource="jdbc">
<field column="topic" name="topic"/>
<field column="info" name="info"/>
</entity>
</document>
</dataConfig>
schema.xml
I put the definitions of fields here.
<schema name="oracle_help" version="1.1">
<fieldType name="string" class="solr.StrField"/>
<field name="topic" type="string" indexed="true" stored="true" multiValued="false"/>
<defaultSearchField>info</defaultSearchField>
<field name="topic" type="string" indexed="true" stored="true"/>
<field name="info" type="string" indexed="true" stored="true"/>
</schema>
solrconfig.xml
Since the configuration file is big and it includes everything. I will take only some excerpts from this configuration file which is related to the Oracle configuration as follows:
I specify which field (topic) I want it to index:
<initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell,/browse">
<lst name="defaults">
<str name="df">topic</str>
</lst>
</initParams>
Under processor section, I have only one default field type defined as string:
<processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
<str name="defaultFieldType">strings</str>
...
</processor>
Then I tried importing the datasource via Solr Admin
Using "DataImport" on Solr Admin dashboard, once execute the command, I got this response back which I'm not sure whether it correctly indexed my Oracle table:
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"initArgs": [
"defaults",
[
"config",
"data-config.xml"
]
],
"command": "status",
"status": "idle",
"importResponse": "",
"statusMessages": {}
}
Weird thing is, the status is indicated as "idle".
I tried to execute search query, but it returns error
Use the search query "test" as follows:
$> curl http://localhost:8983/solr/oracle_test/select?q=test&wt=json&indent=true
Solr returns me "undefined field topic".
{
"responseHeader": {
"status": 400,
"QTime": 1,
"params": {
"q": "called",
"indent": "true",
"wt": "json",
"_": "1434341618019"
}
},
"error": {
"msg": "undefined field topic",
"code": 400
}
}
But, as shown at the earlier part, obviously I have already defined the field "topic" in my schema.xml. It seems lack of documentation or guide on Solr official sites and I tried doing some research on Internet, but I've got nothing at all.
Can anybody who might be familiar with Solr - Oracle integration please help me figure this out? Any suggestion?
I think your Solr server should generate an error upon start-up or when you are trying to access the index that uses the schema.xml you have defined. Please have a look into the logs of your solr server.
It has formal errors, these prevent the index from starting and in turn the DIH you have defined from running
<types /> is missing around your field types
<fields /> is missing around your fields
<defaultSearchField /> is missplaced inside your fields
you have defined the field named topic twice
The structure of a schema.xml is documented in Solr's Wiki. A valid version of your schema.xml would look like the sample below.
<schema name="oracle_help" version="1.1">
<types>
<fieldType name="string" class="solr.StrField"/>
</types>
<defaultSearchField>info</defaultSearchField>
<fields>
<field name="topic" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="info" type="string" indexed="true" stored="true"/>
</fields>
</schema>
The approach which you are using seems to be fine. In solrConfig.xml try using below line
<str name="config">/path/to/my/DIHconfigfile.xml</str>
instead of <str name="df">topic</str>

Get component parameters return empty value on joomla 3.4.1

I have in my component in admin section my "config.xml", the config inputs are ok on the administration of Joomla.
I have for example a field with "my_custom_test" and I set a value, for example "test". I click on "save" button.
If I'm in a view and I want to get my value I'm writing that
$compo_params = JComponentHelper::getParams('com_xxxxx');
var_dump($compo_params).'<br />';
echo $compo_params->get('my_custom_test', 'EMPTY');
The result is that
object(Joomla\Registry\Registry)#19 (2) { ["data":protected]=> object(stdClass)#20 (1) { ["params"]=> object(stdClass)#57 (1) { ["my_custom_test"]=> string(4) "test" } } ["separator"]=> string(1) "." }
EMPTY
The result is "EMPTY" instead of "test".
Do you have any idea ?
Actually I have found the source of the problem, it is in the component config.xml file. If you have the parameters enclosed in a tag (which was the standard practice for Joomla in the past), then the parameters are stored inside an object called "params", eg
<?xml version="1.0" encoding="utf-8"?>
<config>
<fields name="params" label="Some label">
<fieldset name="basic" label="Basic Options" description="">
<field name="some_option" label="label" type="text" description="" />
</fieldset>
</fields>
</config>
To correct the problem, just leave out the tag:-
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset name="basic" label="Basic Options" description="">
<field name="some_option" label="label" type="text" description="" />
</fieldset>
</config>
If you look at any of the core Joomla component config.xml files this is how they do it now.
Then the standard method of getting the component params works:-
$compo_params = JComponentHelper::getParams('com_xxxxx');
$my_custom_test = $compo_params->get('my_custom_test', '');
The solution is
echo $compo_params->get('params')->my_custom_test;

Resources