I am trying to build a KQL Query using KeywordQuery.
I have some managed properties columns that I want to display in the result table but it's not working for me.
here is the code:
oKeywordQuery = new KeywordQuery(oSite);
oKeywordQuery.SelectProperties.Clear();
oKeywordQuery.QueryText = sQuery;
oKeywordQuery.KeywordInclusion = KeywordInclusion.AllKeywords;
oKeywordQuery.StartRow = 0;
oKeywordQuery.RowLimit = 500;
oKeywordQuery.EnableNicknames = true;
oKeywordQuery.EnablePhonetic = true;
oKeywordQuery.TrimDuplicates = false;
oKeywordQuery.SelectProperties.Add("IsDocument"); //This one as a test I was able to display but no managed properties
foreach (string sDisplayField in oDisplayFields)
{
oKeywordQuery.SelectProperties.Add(sDisplayField);
}
oSearchExecutor = new SearchExecutor();
oResultTableColl = oSearchExecutor.ExecuteQuery(oKeywordQuery);
var oResultTable = oResultTableColl.Filter("TableType", KnownTableTypes.RelevantResults);
oRTable = oResultTable.FirstOrDefault();
I am able to get results but no managed properties columns are shown.
What seems to be the problem?
Eventually I figured out that I had WHITE SPACES in the properties string.
For example:
oKeywordQuery.SelectProperties.Add(" MyPropTitle ");
Should be:
oKeywordQuery.SelectProperties.Add("MyPropTitle");
Related
I'm new in developing acumatica I am stuck at getting the value of a custom TextEdit field that I created. I can get all of the built-in field value through this code
InventoryItem items = (InventoryItem)Base.Item.Cache.Current;
but I cannot get the one that I have created at acumatica customization
here is the field I want to get
https://i.stack.imgur.com/gPln4.png
I already tried
InventoryItem items = (InventoryItem)Base.ItemSettings.Cache.Current;
var shortdesc = items.UsrShortDescription;
But it's not working and does not show the value inside the textbox
thank you in advance for helping
InventoryItem items = (InventoryItem)Base.ItemSettings.Current;
var itemExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(items);
var shortdesc = itemExt.UsrShortDescription;
Vardan showed one way, for completeness of picture want to show another as well:
InventoryItem items = (InventoryItem)Base.ItemSettings.Current;
var itemExt = items.GetExtension<InventoryItemExt>();
This is an example of getting value from a non-extension field. I did not use extension DAC to add the Gift card field to the store setup screen.
In a method I need to get the value of that field. I should check whether the order contains Gift card item or not.
public static bool GiftcardName(OrderModel orders, BZWoocommerceStore store)
{
// "ZGift CArd W" => "giftcard"
string wooCommName = string.Empty;
string wooCommNameNoSpases = string.Empty;
bool containsGiftcardName = false;
bool isGiftcard = false;
foreach (OrderLineModel line in orders.LineItems)
{
string gNameInAcumatica = store.GiftcardIdentifier;
string gNameInAcumaticaWithoutSpaces = gNameInAcumatica.Replace(" ", "");
wooCommName = line.Name; //pattern
wooCommNameNoSpases = wooCommName.Replace(" ", "");
//wooCommNameNoSpases = new string(wooCommName.ToCharArray()
// .Where(c => !Char.IsWhiteSpace(c))
// .ToArray());
//woCommNameNoUperCase= wooCommNameNoSpases.ToLower();
//isGiftcardName= woCommNameNoUperCase.Contains(gName);
//containsGiftcardName = wooCommNameNoSpases.Contains(gName);
containsGiftcardName = Regex.IsMatch(wooCommNameNoSpases, gNameInAcumaticaWithoutSpaces, RegexOptions.IgnoreCase);
if(containsGiftcardName)
{
isGiftcard = true;
}
}
return isGiftcard;
}
So, when I call this method I give to that 2 arguments, orders and store.
The store argument was created in this way.
public PXSelect<BZWoocommerceOrder> Order;
In an action method I wrote this.
string storeCode = this.Order.Current.StoreCode;
BZWoocommerceStore store = PXSelect<BZWoocommerceStore, Where<BZWoocommerceStore.storeCode, Equal<Required<BZWoocommerceStore.storeCode>>>>.Select(this, storeCode);
My GiftcardName() method sees the value of original field. Writing "Original" I mean that you do not use any technique like this one.
BZSOOrderExt rowExt = sender.GetExtension<BZSOOrderExt>(row);
I have saved data in table PollCollection(PollID, PollName, VotingClass) and OptionCollection(OptionID, PollID, Option). I have a class called Poll, in which string PollTitle and LinkedList option can be saved (and others). I read my first PollName from PollCollection with appropriate VotingClass and then try to read Option from OptionCollection where PollID = PollCollection.PollID. However, my options cursor has a length of 0.
I know for a fact that the OptionCollection is saved properly, because in another piece of code I managed to run a select * query and printed all the appropriate values. At this point, I have no idea what am I missing. Also, I am working with Xamarin Android.
string pollquery = "";
string optionsquery = "";
pollquery = string.Format("select * from PollCollection where PollCollection.VotingClass = '{0}'", userclass);
ICursor polls = MainActivity.sqlitedb.RawQuery(pollquery, null);
if (polls.Count > 0)
{
polls.MoveToFirst();
do
{
Poll currentpoll = new Poll();
currentpoll.PollTitle = polls.GetString(polls.GetColumnIndex("PollName"));
string pollid = polls.GetString(polls.GetColumnIndex("PollID"));
optionsquery = string.Format("select Option from OptionCollection where OptionCollection.PollID = '{0}'", pollid);
ICursor options = MainActivity.sqlitedb.RawQuery(optionsquery, new string[] { });
options.MoveToFirst();
do
{
currentpoll.Options.AddLast(options.GetString(options.GetColumnIndex("Option")));
} while(options.MoveToNext());
polllist.AddLast(currentpoll);
} while (polls.MoveToNext());
}
I have created a dynamic query which can return a dataset from an external BAQ. I want the dyanmic query to only return the records which meet the parameters I have parsed.
This is the code I have so far:
// DynamnicQuery for BAQ
Epicor.Mfg.Core.Session epiSession = default(Epicor.Mfg.Core.Session);
epiSession = (Epicor.Mfg.Core.Session)POEntryForm.Session;
DynamicQuery dynamicQuery = new Epicor.Mfg.BO.DynamicQuery(epiSession.ConnectionPool);
//Build Data Set
QueryExecutionDataSet executionDS = new QueryExecutionDataSet();
//Build parametors
QueryExecutionDataSet parameters = new QueryExecutionDataSet();
DataRow paramRow = parameters.ExecutionParameter.NewRow();
paramRow["ParameterName"] = "POSuggestionsView.PartNum";
paramRow["ParameterValue"] = "10050886";
paramRow["ValueType"] = "nvarchar(50)";
paramRow["IsEmpty"] = "False";
paramRow["RowIdent"] = "";
paramRow["RowMod"] = "";
paramRow["DBRowIdent"] = new byte[0];
parameters.ExecutionParameter.Rows.Add(paramRow);
// Out variable which indicates if more results are available (likely for use with topNRecords)
bool hasMoreRecords = false;
//Executed named BAQ with parameter...
DataSet results = dynamicQuery.ExecuteByIDParametrized("AD-999-SB_POSuggestion", parameters, "", 0, out hasMoreRecords);
//Message Each Description....
MessageBox.Show("Number of rows in Results = " + results.Tables["Results"].Rows.Count.ToString());
foreach (DataRow item in results.Tables["Results"].Rows)
{
MessageBox.Show("Row Value = " + item["POSuggestionsView.PartNum"].ToString());
}
The code I have created still returns all of the values from the table without restricting the returned rows to the ones which meet the condition of the parameter. Can anyone help me as to why this is happening please?
You need to create a Parameter in the BAQ.
Open the BAQ editor and navigate to the Phrase Build tab, select the table you want to add the parameter to.
Add a new criteria to the table in the section below, the filter type will be "Specified Parameter". Take note of the parameter name.
Save the BAQ.
Back in your customization modify the paramRow["ParameterName"] = the parameter name you created in the BAQ.
Cannot find any documentation for this...
Currently using the following code to get a list of my photos:
FacebookApp fb = new FacebookApp(accessToken);
dynamic test = fb.Get("me/photos");
I'm cycling through the first 25 photos that it returns. Simple.
Now how do it get it to return the next 25?
So far I've tried this:
FacebookApp fb = new FacebookApp(accessToken);
string query = "me/photos";
while (true)
{
dynamic test = fb.Get(query);
foreach (dynamic each in test.data)
{
// do something here
}
query = test.paging.next;
}
but it fails throwing:
Could not parse '2010-08-30T17%3A58%3A56%2B0000' into a date or time.
Do I have to use a fresh dynamic variable for every request, or am I going about this the wrong way completely?
Ended up finding this:
// first set (1-25)
var parameters = new ExpandoObject();
parameters.limit = 25;
parameters.offset = 0;
app.Api("me/friends", parameters);
// next set (26-50)
var parameters = new ExpandoObject();
parameters.limit = 25;
parameters.offset = 25;
app.Api("me/friends", parameters);
I also found you can use this.
// for the first 25 albums (in this case) 1-25
dynamic albums = client.Get("me/albums", new { limit = "25", offset = "0"});
// for the next 25 albums, 26-50
dynamic albums = client.Get("me/albums", new { limit = "25", offset = "25"});
Worked the same as you used above.
This code works correctly to make a web service call:
int numberOfGuests = Convert.ToInt32(search.Guest);
var list = new List<Guest>();
Guest adult = new Guest();
adult.Id = 1;
adult.Title = "Mr";
adult.Firstname = "Test";
adult.Surname = "Test";
list.Add(adult);
Guest adult2 = new Guest();
adult2.Id = 2;
adult2.Title = "Mr";
adult2.Firstname = "Test";
adult2.Surname = "Test";
list.Add(adult2);
Guest[] adults = list.ToArray();
How do I build the list dynamically using the numberofguests variable to create the list? The output has to match the output shown exactly else the web service call fails, so adult.id = 1, adult2.id = 2, adult3.id = 3, etc...
Do you know about loops?
for (int i = 1; i <= numberofGuests; i++) {
var adult = new Guest();
adult.Id = i;
adult.Title = "Mr";
adult.Firstname = "Test";
adult.Surname = "Test";
list.Add(adult)
}
This runs the code within the loop once from 1 to numberOfGuests, setting the variable i to the current value.
The Linq way :-)
var list = (from i in Enumerable.Range(1, numberOfGuests)
select new Guest
{
Id = i,
Title = "Mr.",
Firstname = "Test",
Surname = "Test"
}).ToList();
You need a for loop. Or, better yet, a decent C# book -- these are really basics of C#.
Are you asking how to display a list dynamically? I'm not really sure what the question here is about, as the other answers say if you know the value of numberofGuests then you can just use a loop to go through your list.
I suspect you are wondering how to obtain this information in the first place, am I right? If you want to dynamically add controls to a page (your previous post suggest this was ASP.Net I think?), so that you only display the correct number of controls then take a look at these related questions:
Dynamically adding controls in ASP.NET Repeater
ASP.NET - How to dynamically generate Labels