How to pxselect and get extension of selected - c#

Hi im new in acumatica programming i have a code that gets the row of my data then i want to get the extension of that row how do i do it here is what i got so far
InventoryItem sel = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<CROpportunityProducts.inventoryID>>>>.Select(Base, items.InventoryID);
var selex = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(sel);
how do i get that extension as you can see i tried PXCache. Get Extension but i have no luck on it. so my question is how to get the extended value of acumatica PXSELECT thanks in advance

It would help to know in which context this code is executed but the following should work.
InventoryItemExt selExt = sel.GetExtension<InventoryItemExt>();

InventoryItem sel = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<CROpportunityProducts.inventoryID>>>>.Select(Base, items.InventoryID);
if(sel != null){
InventoryItemExt selExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(sel);
}

Related

Selenium C# Find Element with class and text

im very new to testing and have no training in automated tests so please bare with me if i say stupid things but ill try the best i can.
Bascially i am trying to assert that a specific employee in the employee list has the status of 'leaver'.
This is what i have tried (and other variations with the different classes)
Assert.Equal("image-tile__badge background-color--status-leaver ng-star-inserted", Driver.FindElement(By.XPath("//*[contains(#class,'image-tile__content-header') and contains(text(),'End Date, Contract') and contains(#class, 'image-tile__badge')]")).GetAttribute("Class"));
Assert.Equal("image-tile__badge background-color--status-leaver ng-star-inserted", Driver.FindElement(By.XPath("//*[contains(#class,'image-tile__content-header') and contains(text(),'End Date, Contract')]")).FindElement(By.XPath("//*[contains(#class, 'image-tile__badge')]")).GetAttribute("Class"));
The last one finds the element when the status is 'new', but when i change the employee status to 'leaver', it still returns as 'new' so possibly looking at another employee with a 'new' status.
Hopefully this is enough info, let me know if more is needed (this is my first ever post!)
HTML code in image below
[HTML code on Chrome]
[1]: https://i.stack.imgur.com/kUxkf.png
Summary: im trying to assert that the Employee "End Date, Contract" has the status of leaver (aka the leaver class "image-tile__badge background-color--status-leaver ng-star-inserted")
Thanks everyone for their help!
One of my devs managed to take #noldors example and modify it a bit so heres what ended up working for me:
var newElmList1 = Driver.FindElements(By.CssSelector("div.background-color--status-leaver")).ToList();
List<string> newNames1 = new List<string>();
foreach (var newElm in newElmList1)
{
var newName1 = newElm.FindElement(By.XPath(".."))
.FindElement(By.CssSelector("div.image-tile__content-header")).Text;
newNames.Add(newName1);
}
if (!newNames.Contains("End Date, Contract"))
{
throw new Exception("Exception Error on leaver Person");
}
As per your screenshot i fill it's better if you try using Xpath
var elmList = Driver.FindElements(By.Xpath("//div[contains(text(),'leaver')]")).ToList();
i hope it will help you
Thank You.
According to your screenshot, you can find all elements with 'Leaver' specific class with this;
var leaverElmList = Driver.FindElements(By.CssSelector("div.background-color--status-leaver")).ToList();
List<string> leaverNames = new List<string>();
foreach (var leaverElm in leaverElmList) {
var leaverName = leaverElm.FindElement(By.XPath(".."))
.FindElement(By.CssSelector("div.image-tile__content-header"));
.Text()
leaverNames.Add(leaverName);
}
Enddate, Contract which is not related to the div that contains Leaver. It's direct parent is the image-tile div

address an object by retrieving the ID name of the object from a variable

Good evening,
I am trying to get the following done. I have seen a similar post but it was related with Unity.
Anyway, I am on web forms in asp.net and I have a radiobuttonList with ID="id001"
so on my code behind, I would normally be able to get the selected value by just doing:
string value = id001.SelectedValue
However, in this situation, I don't know the exact ID name, so I have a function that retrieves it. So now I have the variable with the name of the ID. So I want to be able to now, convert the value of that variable in something like this:
string foundid = "id001"
string foundidvalue = id001.SelectedValue
I hope this makes sense.
Thanks in advance for the help.
I am assuming this one is related to your previous question. So, when you found the control, instead of using function to get the fullname, you can do like this:
foreach (Control c in Page.Form.Controls.OfType<RadioButtonList>())
{
if (c.ID.Contains("id"))
{
// string FullID = c.ID.ToString();
var radioButtonList = c as RadioButtonList;
var selectedValue = radioButtonList.SelectedValue;
}
}
You want to use FindControl.
string foundid = "id001";
var foundCtrl = (RadiobuttonList)FindControl(foundid);
var result = foundCtrl.SelectedValue;

Paging of RSS using System.ServiceModel.Syndication

I'm trying to achieve pagination of the posts i get from a RSS-feed using the System.ServiceModel.Syndication. However I cant figure out how to do this and what the best way to do it is.
As of now i use a Listview to present the data that is fetched by this in my code-behind:
// Link to the RSS-feed.
string rssUri = "feed.xml";
var doc = System.Xml.Linq.XDocument.Load(rssUri);
// Using LINQ to loop out all posts containing the information i want.
var rssFeed = from el in doc.Elements("rss").Elements("channel").Elements("item")
select new
{
Title = el.Element("title").Value,
PubDate = el.Element("pubDate").Value,
Enclosure = el.Element("enclosure").Attribute("url").Value,
Description = el.Element("description").Value
};
// Binding the data to my listview, so I can present the data.
lvFeed.DataSource = rssFeed;
lvFeed.DataBind();
So where do I go from here? I'm guessing one way is to work with a DataPager in my Listview? However I'm uncertain how to work with that control, should I send all of my data into some list or something like IEnumerable<>?
After some trial and error and reading up on the DataPager i came up with the following solution that is now working very well!
First off i created a class for my object, working with that i set up a select-method for my ListView initiating at page-load binding the data to it. And the trick here was to use the ICollection interface, and send the data to a list. This is the now working code for that select-method, hope it can help someone else out facing the same problem! :)
ICollection<Podcast> SampleData()
{
string rssUri = "http://test.test.com/rss";
var doc = System.Xml.Linq.XDocument.Load(rssUri);
ICollection<Podcast> p = (from el in doc.Elements("rss").Elements("channel").Elements("item")
select new Podcast
{
Title = el.Element("title").Value,
PubDate = el.Element("pubDate").Value,
Enclosure = el.Element("enclosure").Attribute("url").Value,
Description = el.Element("description").Value
}).ToList();
return p;
}

get the description field of a sitefinity classification in code

I am new to sitefinity, I am looking for a way to the access the description field of the classification in my code.
Please let me know how I can do that.
I have written code that gets me all the classifications(hierarchial taxonomy) in the form of a tree that I am binding to a RadTreeView control.
Each node in the RadTreeView control has properties like text, navigateURL etc. but no Description. I assume I have to do it differently to get the description field.
Any help or direction is appreciated. It looks to me like a very basic implementation to get the description but not able to get it.
Thanks!
Below is a function that uses the Sitefinity API to look up a Category by Title.
You'll need the following using statements:
using Telerik.Sitefinity.Taxonomies;
using Telerik.Sitefinity.Taxonomies.Model;
I've added the line that gets the description to hopefully better answer your question.
private Taxon GetCategoryByTitle(string category)
{
var manager = TaxonomyManager.GetManager();
var categoriesTaxa = manager.GetTaxonomy<HierarchicalTaxonomy>(TaxonomyManager.CategoriesTaxonomyId);
var taxomony = categoriesTaxa.Taxa.FirstOrDefault(t => t.Title == category);
var description = taxomony.Description; //get description here
return taxomony;
}

BindindSource Filter does not work

Please see the following code on a Winform Load method:
List<CustomersDTO> res = new List<CustomersDTO>();
res = _CustomerBO.GetCustomers();
customerBindingSource.DataSource = res;
customerDataGridView.DataSource = this.customerBindingSource;
customerBindingNavigator.BindingSource = this.customerBindingSource;
Now I want to filter on Searchbutton but I am not able to see filtered record on screen.
customerBindingSource.Filter = "Active = false";
I am missing something.. I did reasearch. Can anybody give me exact code example? I read about implementing IBindingList but not sure how to do that with my BindingSource..
Can anyone help?
You don't have to implement IBindingList. You can construct a BindingList as the DataSource of your customerBindingSource. Like This:
customerBindingSource.DataSource = new BindingList<CustomersDTO>(res);

Categories

Resources