Drupal 7 Views Multiple Contextual Filters - filter

I'm running Drupal 7 with Organic Groups. I cloned the "OG all user group content" view added an Entity Reference to it to be used as a field in one of my content types. My question is:
How can I use an additional contextual filter (Content Type) so that I can add an Argument to the Entity Reference field?
Entering the content type name isn't working: 1/article for example.

So I got the answer from:
https://drupal.stackexchange.com/questions/53861/how-to-show-nodes-of-a-content-type-using-contextual-filters-as-filters
Adding "Content Type" contextually typically requires a Node ID however; using PHP Code you can simply add:
return TRUE;
and this will allow you to enter the content type name (the physical name; i.e. OpenLayers Location field is named Location but the physical path is ol_locator_location).

When you edit the view in the Advanced link, you can see "Contextual Filter"; there you can add the field you added to the content type.

Related

How to retrieve addresses using the odata endpoint

I'm trying to retrieve an address on a standard entity.
the request is the following :
https://mycrm.api.crm4.dynamics.com/api/data/v9.1/contacts(guid)
In this example, I get all fields, but the ones that is of interest to me is address1_addressid, which seems to be a Guid, referencing some of record, but I cannot find it in the "Many to One" relationship list I retrieved using the following command :
https://mycrm.api.crm4.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName='contact')?$select=LogicalName&$expand=ManyToOneRelationships($select=ReferencingAttribute,ReferencedEntity)
I would like to retrieve those addresses in a generic manner, as I'm working on a generic NetStandard 2.0 library. I won't be able to know on which entity I'll be working, and thus won't be able to hard-code a list of addresses field names.
Here's one way to find the Contact to Address relationship:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName='customeraddress')?$select=LogicalName&$expand=ManyToOneRelationships($select=ReferencingAttribute,ReferencedEntity)
I got an error with https://myOrg.api.crm.dynamics.com/api/data/v9.1/contacts(guid)?$expand=address1_addressid.
I looked into the MetaData and discovered that address1_addressid has a type of Primary Key:
While a normal lookup field has a type of Lookup:
Considering the error message that appears when attempting to expand address1_addressid, I think the issue is address1_addressid's data type.
Property 'address1_addressid' on type 'Microsoft.Dynamics.CRM.contact'
is not a navigation property or complex property. Only navigation
properties can be expanded.
It would seem that rather than using $expand to get the address details, you'd have to make a separate call for it:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/customeraddresses(guid)
UPDATE
By reviewing the full Contact-Address relationship, via this query: https://myOrg.api.crm.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName='customeraddress')?$select=LogicalName&$expand=ManyToOneRelationships.
I discovered the ReferencedEntityNavigationPropertyName was set to Contact_CustomerAddress.
The error message before talked about the Navigation property so I gave it a shot. Using that property named allowed me to expand the Address info from the Contact:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/contacts(guid)?$expand=Contact_CustomerAddress
Interestingly, expanding that navigation property returns all 3 customer addresses:

InstallShield: Get the organization name during installation

I'm creating an installation with instalshield.
In the "Installation Interview", (which is part of the "Project Assistant") I set the option "to prompt users to enter their Company Name".
My question is: how can I interact with the value they entered? I mean how can I get it? I need to take this value and insert it to my app config file , during the installation process.
In a more general way, I would love to know how can I add text fields of my own and interact with the values the customers insert?
Thank you,
Noam
Look at the installation Wizard Noam. Anywhere you see an edit control, you will notice that it has a property associated with it. The property is a 'variable' that will have a value assigned to it. You can use the property to populate a registry, an XML file, etc.
I would look through the help documentation for InstallShield relating to Properties.
http://helpnet.flexerasoftware.com/isxhelp19/helplibrary/IHelpISXPropertiesUse.htm
The link above goes over the difference between Public and Private properties and how you can use them.
Ok, so I sort of solved it, I didn't use any built in dialog boxes, but simply created my own public property and dialog, then added an event to dialog and finally read the property value with powershell script, in more details (for future noobies) :
Create new property in Property Manager (under "Behavior and Logic"), give it a name and default value.
Create new dialog (under "User Interface").
At the behavior section of your dialog go to "Next" control (for example).
Add event (by pressing the tiny green plus sign at the line of the "Events")
Choose "SetProperty"
At the SetProperty line you can specify a condition, for example ApplicationUsers = "AllUsers"
At the "Property" field enter the property name (from first instruction)
At the "Value" field enter the value you wish for.
For getting the property value from powershell, create powershell script with the following: $value = Get-Property -Name PROPERTY_NAME
That's it.
This is not exactly what I asked for in the question but I believe this answer is more general and so also contains the answer to my original question.

Why Collection-valued navigation properties return empty list and a reference link to the actual data in CRM 2016 WEB API

I don't know why the collection-valued navigation properties are always return an empty list with a reference to the actual data link.
here's the query I tried :
GET <organization>/api/data/v8.0/new_subjectareas?$expand=new_product_new_subjectarea&$count=true
Response :
{
"#odata.context":"<organization>/api/data/v8.0/$metadata#new_subjectareas",
"#odata.count":150,
"value":[
{
"#odata.etag":"W/\"9644599\"",
"timezoneruleversionnumber":null,
"processid":null,
"_stageid_value":null,
"new_product_new_subjectarea":[],
"new_product_new_subjectarea#odata.nextLink":"<organization>/api/data/v8.0/new_subjectareas(622bcca9-8946-e511-80fb-00155d002810)/new_product_new_subjectarea"
},
....
How can I get the items within the navigation property (new_product_new_subjectarea) without make a new request to it's reference (new_product_new_subjectarea#odata.nextLink)?
The behaviour you are seeing is "by design" (even if one could argue that this particular design choice is questionable).
When you expand a collection-valued navigation property, you will always get an empty array plus a [relation name]#odata.nextLink property. There is currently no way of getting the actual relation rows without making an additional request.
Source: the example in the official documentation.
It looks like you are returning to many entities.
source: https://msdn.microsoft.com/en-us/library/gg334767.aspx#bkmk_limits

Field returns empty string

I create a new profile document with the following code:
Set doc = db.Createdocument()
doc.Form = "SMBPrivateProfile"
Call doc.Computewithform(True,True)
Call doc.Save(True, False)
But whenever I want to read a field by #GetProfileField i get an empty string, even if the field I want to read has a default value.
After opening & saving the document manually everything works.
Further details:
I improved an application and hit Application --> Replace Design.... The new version includes a new field within the profile document. When reading one of these new fields, the result is an empty string. When reading an 'old' field within the same document the result is the expected string.
e.g.:
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "OLD_FIELD"; #ThisName))
--> Will result in: "This is a fancy old default value"
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "NEW_FIELD"; #ThisName))
--> Will result in: "" (instead of "This is a fancy new default value")
That's not a profile document. To create profile document use:
db.GetProfileDocument("SMBPrivateProfile");
You can also add a second parameter for a unique key in addition to profile name.
Also consider if you really want to use profile documents. They are heavily cached and not visible in any views.
If I'm reading you right, it appears that you have updated a form and added a new field with a default value formula. You are then reading an existing document. When you do this, the new field that you added to the form does not yet exist. New fields and formulas aren't applied to existing documents until you do something to force them to be applied.
If it's a regular document (as your original code indicated), you can just open the document in the Notes client, edit, and re-save it. That will create the NEW_FIELD and give it its value. If there are lots of these documents, you could write a simple formula agent to do this via #Command([ToolsRefreshAllDocs]) or #Command( [ToolsRefreshSelectedDocs]).
If it is a profile document (as per the responce chain to #Panu's anser), then after you do the replace design you will have to write an agent to open the existing profile document using db.getProfileDocument use doc.ReplaceItemValue("NEW_FIELD";"new value").

Drupal 7: Combining multiple content type in single view

I have a content type called Author which is referred in another two content types called Novel and Book via Node Reference Module.So we can add author entity to both Book and Novel content types.
Both Novel and Book contain another field called Release Date.
Now I want to show a block which will display the name of book and name of novel in chronological order based upon the release date when user come to that corresponding Author Page.
Ex. Suppose A is an author who is author of BookA(Release Yr-2006), NovelB(Release Yr-2004),BookC(Release Year-2009). When user come to Author A page then he will be shown a block which will show the Books/Albums in chronological order like this:-
NovelB--BookA--BookC
Please suggest as how to achieve in Drupal 7.
You want to display the following field title (I assume the book name is the node title)
For the sorting you can use the sort option in views, it is pretty self-explaining. Choose the name of your release date field.
For the connection between author and books you will have to use a contextual filter (advanced).
Add the author-reference-field from your book/novel (the field you use to refer to the author). Then choose to use a default value (2nd option) and choose content id from url. Now your block will find all nodes that refer to the page with the current page-id. Since we chose to display the title fields, you should see a list.
Note that live preview does not work here, so you will have to go to the actual page to see the result.
UPDATE:
This works when you have re-used the same field for both content types. If you have uses more then one field you will have to use an OR operator to make the contextual filter work. Thanks to d34dman the following page was given to do just that.
Although for new implementations I would recommend using the same field (eg. reference_to_author) for all references from all content types.
Yah..I am able to solve this problem by adding custom code. I have used hook_views_query_alter method and then added join relationship and where clause as per requirement. Please refer to following article for more clarity..
http://www.midwesternmac.com/blogs/jeff-geerling/filtersearch-multiple-fields
Thanks for posting the reply and keeping my hope alive.

Resources