How to filter REST control based on dojo grid selection? - dojo

On an Xpage I have two REST controls that populate two enhanced dojo data grids. One is populated with companies, the other I would like populated with the contacts of the selected company. I am able to select a company and display the UNID of that document in a field on the xpage. I am having difficulty filtering the contact grid based on that UNID. What is the best way to do that? Below is what I have tried
Populate the ParentID field with the selected doc UNID using (CSJS):
var grid = arguments[0].grid;
var index = arguments[0].rowIndex;
var item = grid.getItem(index).attributes;
XSP.getElementById("#{id:ParentID}").innerHTML = item.companyLink;
XSP.partialRefreshGet("#{id:contactListPanel}")
Retrieve the UNID from Parent ID and use in the keys parameter of the contact REST control using (SSJS):
getComponent("ParentID").getValue()
It looks like the contact grid is refreshing when a company doc is selected, however all the contacts for all companies appear in the contact grid no matter what company is selected.

Probably, ParentID field doesn't get submitted to server and isn't available as parameter for REST service.
Transfer company's UNID as parameter in partialRefreshGet() instead
XSP.partialRefreshGet("#{id:contactListPanel}",
{params: {'unidCompany': item.companyLink}})
Read the parameter on server side with
param.unidCompany
and use it as parameter for REST service.

Related

ASP.NET Core Filtered Dropdown List does not display previously entered value

I have an ASP.NET Core web application with a dropdown list on an edit page. It is a SQL back-end. One of my fields is "Project Manager" which populated from the "Users" table.
So people do not select retired or inactive users, there is a Boolean field in SQL called "Active" which is true for active users and false for former users.
I filter my select list based on this attribute and it correctly displays only current users.
However, if an existing record has an inactive user in the Project Manager field, it shows as null when you open the edit page.
Is there a way to retain the existing value on the edit page when the value does not exist in the select list?
Alternately, is there another way to do this?
In case of no records you can Concat the 'Default' data with you list. With this if your list returns empty records, it will be concated with default and there will be one default option.
OR
You can Set some hardcode value for the dropdown list if it return null or empty. In this case your hardcoded data will be populated on UI if no records found in list.
I got it to work using the following:
#{
if (Model.Projects.ProjectManager.HasValue &&
Model.Projects.ProjectManagerNavigation.Active == false)
{
int pm = (int)Model.Projects.ProjectManager;
<option value="#pm">#Model.Projects.ProjectManagerNavigation.FullName</option>
}
else
{<option disabled selected>--- SELECT ---</option>}
}
Inside of the Select Tag for that field.
It checks if the Project Manager field has a value, and if that user is Inactive and just adds a select list option for the existing user, even though they are no longer in the filtered select list.
Thanks for the answer Sachin, I just needed to work out how to get that implemented.

Can we send multiple Properties in Json of Analytics(IBM MobileFirst)

I was asked for a usecase where I have to filter ActionEvents on type of Page that action is being is being called from.
Example
use case: I have a login page and I have to capture analytics of its events
Can I do something like this
String json = {"PageLevel":"LoginPage","ActionLevel":"LoginButton"};
WLAnalytics analytics=new WLAnalytics();
analytics.log(message, new JSONObject(json));
Will this work... can we create custom chart with first property being ActionLevel and filter it as per PageLevel.
No this will not work. Custom analytics can only be logged in key value pairs i.e. you cannot send two key value pairs in one JSON object. This is a good idea though, I recommend you submit an RFE.
Submit a Feature Request

Sitecore REST API search By Navigation Category

I am working on building a REST API based connector to a marketplace which uses sitecore. I have found the documentation for using the search API command here:
https://sdn.sitecore.net/upload/sitecore6/65/sitecore_search_and_indexing_sc60-65-a4.pdf
I have been unable to figure out how to use it to search for content that is grouped into a navigation category, and was unsure if there was a good way to do this. I did not design the site, and the designers were contractors who are no longer working with us.
I would like to be able to find a list of items based on a specific navigation category that has been assigned to them. I have tried getting the children of the category ID itself, but that did not work. Here is a picture of the navigation category associated with a given object in case it adds clarification:
enter image description here
Is there an easy way to search for items like this?
Going with the assumption that you are on 7.2 or above, you just need to search for items that have the ID of the Navigation Categorization field (in your index as navigation_categorization) that are set to the ID of the item you wish to filter on. In your image, it would be the ID of "connectivity services" item.
var context = ContentSearchManager.GetIndex("master").CreateSearchContext();
var computedLanguage = Sitecore.Context.Language.CultureInfo.Name;
// get the iBuild items
var results = context.GetQueryable<SearchResultItem>()
.Where(i => i["navigation_categorization"].Contains([connectivity services ID])
&& i.Language == computedLanguage)
.GetResults()
.Hits.Select(x => x.Document.GetItem(
));

How to display custom fields in rally?

I have a ruby script that is trying to pull up some custom fields from Rally, the filter works just fine ( the filter contains one of the custom fields i want to pull up) but when I try to display it, it doesn't show up in the list (the value returned for all custom fields is blank, while appropriate values are returned for FormattedID, Name, Description).
Here's the link [link]http://pastebin.ubuntu.com/6124958/
Please see this post.
Do you fetch the fields?
What version of WS API are you using? If it is v2.0 is c_ prepended to the name of the field in the code?
How is the field spelled in your code and how that spelling compares to Name and Display Name of the field in UI?
There is another reason why custom fields might not appear (other than the versioning and 'c_' issues nickm mentioned). I just found this out after a ton of head banging. The Rally SDK's ui stuff will filter out all fields that are hidden (such as _ref, or other 'hidden' custom fields) so you cannot view them in your apps in grids, charts, etc. For example, when constructing a Rally.ui.grid.Grid, a class called Rally.ui.grid.ColumnBuilder is constructed and it executes a command on the columns of the chart that look like this:
_removeHiddenColumns: function (columns) {
return _.filter(columns, function (column) {
return !column.modelField || !column.modelField.hidden;
});
},
As you can see, if you try to display any fields that are hidden (like _ref for example) in a grid, the column gets removed. So, although you may be fetching the custom fields, they will not show up unless those fields are not 'hidden'.

Kentico Ecommerce: getting top selling categories

I am using Kentico 7.0, ecommerce version.
I would like to create a sidebar menu that shows the eshop's top selling product categories. I am a kentico newbie so I am looking around for the correct terminology/guidance so that I can dig deeper.
The ideal approach in my opinion would be to be able to add a field on categories, which is used to filter categories for the menu. This way I can either have some kind of job that updates the fields automatically based on sales, OR provide a manual override for an admin to specify whether a category will show up on the menu. Of course some kind of weight would also be needed to specify menu item ordering.
Which way should I look?
HAve you tried using the "Top N products by sales" web part that is available? you can configure from which part of the content tree (products) it should pull the data - in the Path property you can use also a path expression or macro that is resolved dynamically so the web part can display different products in different sections.
There are many ways to code for Kentico. I personally find the API is a bit clunky and on quite a few occasions I was surprised that a method didn't exist requiring extra calls to get the required results. I do use the Kentico API more when putting data in to Kentico. Pulling it out I use the following.
STORED PROC
Write a SQL stored procedure to get the top X categories - GetTop5Categories.
Look at the COM_* tables, specifically COM_OrderItem, linking OrderItemSKUID back to COM_SKU (or View_COM_SKU_Joined if you need to get to the IA).
This will get you the top selling products with a group by, a count, a top X and an order by.
Then you can link to other tables such as CMS_Category or CMS_Document (depending on how you setup your categories). The bonus of this is that procs are compiled, you do all your data manipulation there (it's what MSSQL specialises in!) and you only send back what you need to in the result set.
DOMAIN (leveraging EF)
I usually create a separate class library project myproject.domain and put an Entity Framework edmx in there mapped back to the Kentico DB. Add the proc to the EDMX, then create a Function Import MyProject_GetTop5Categories from your newly imported proc.
WEB
add a reference to the domain project from your web project, and a 'using at the top of the codebehind of the control.
using myproject.domain;
then in Page_Load for the control:
...
if(!IsPostBack)
{
var entities = new MyProjectModelContainer();
var list = entities.MyProject_GetTop5Categories().ToList();
StringBuilder sb = new StringBuilder("<ul>");
foreach(var category in list)
{
sb.Append("<li><a href='"+category.Link+"'>" + category.Name + "</a></li>");
}
sb.Append("<ul>");
listPlaceHolder = sb.ToString();
}
handwritten so probably a typo or two in there :)
HTH