Edit Value in Collection by Index in Blue Prism - blueprism

If I have a collection named CollectionLabels and the content is below
UI Value Label |Backend ->Fields
Label1 |Backend1
Label2 |Backend2
Label3 |Backend3
How can I edit the "Label2" to "Label2_New" by index?
I really want to avoid using the Loop Stage since it's really slow. Is there a way like:
CollectionLabels.UI Value Label (2) = "Label2_New"
I would really appreciate a fast moving code here.

This C# stage assumes that the index you're updating is always of type Text. Should be fairly easy to make modifications to accommodate other data types.
Inputs:
Collection - Collection |
Row - Number |
Column - Number |
newVal - Text
Outputs:
Modified Collection - Collection
Collection.Rows[Convert.ToInt32(Row)][Convert.ToInt32(Column)]=newVal;
Modified_Collection=Collection;

Related

Create custom ID and Description based on values in multiple other cells

I'm looking to auto generate the Fixture ID column and Description Column using several cell values:
The above image includes the required format for both Fixture Id and Description.
Variables for Fixture ID include:
Part Descriptor: Widget Thing = "WT"
Part Length and Strength: 20L = 20" + L strength
Retainer Dimension: 0.75R - 0.75" Retainer
The Description cell simply converts to longer form text with the variables included.
I'm hoping to avoid filling this in manually, but I'm not familiar enough with excel's functions.
This is very difficult to understand your full question considering "Widget Thing" and "WT" are not a part of the base data and only found within the columns you want to automate. So assuming everything is a "Widget Thing", a "Retainer", and a "Spring" this formula will get you started:
Fixture ID
="WT-"&G1:G10&H1:H10&"-"&FIXED(F1:F10,2)&"R"
Description
=G1:G10&""" "&IFS(LEFT(A1:A10,2)="WT","Widget Thing w/ ")&F1:F10&""" Retainer & "&H1:H10&" Spring"
Adjust range as desired, add additional IF parameters if needed.

Create a text cell value based on row entries and corresponding columns

I understand this is a tough way of wording the problem I have. Please try and help me.
I want to create a Column called Orders which contains cells based on corresponding item values.
So if I have columns: FlatNo, Truffle, Pineapple, Mango, Chocochips; I want to create a column called Orders which has value:
FlatNo - A51
Mango - 1
Chocochips - 1
(if no values in the Pineapple & Truffle Columns, none show up in Orders columns)
See image
How do I do that ? Thank you in advance
You can use IF and &. & simply puts the different desired things altogether.
Hope the following formula will get you the result for column orders. I have put the number of each item ordered inside parentheses before the item.
="Flat No. "&A2&IF(ISBLANK(B2),"","-("&B2&")"&$B$1)&IF(ISBLANK(C2),"","-("&C2&")"&$C$1)&IF(ISBLANK(D2),"","-("&D2&")"&$D$1)&IF(ISBLANK(E2),"","-("&E2&")"&$E$1)
For instance the third order is shown like this: Flat No. E-23-(1)Truffle -1 Pc Rs 60-(3)Mango -1 Pc Rs 60

How to generate a three level dependable dropdown list

I am a complete VBA beginner and this is the first time I have had to deal with VBA. My project is simple- a user form which heavily relies on dependent drop down lists. I watched a ton of videos and wrote (more like copy-pasted) code which actually works just fine. My issue is that I need to edit part of my code to add a feature which I have trouble finding a video on (trial and error editing only took me this far).
In it's current state, my form has two dropdown lists drawing information from a sheet where data is arranged in columns as follows:
ITEM ID | ITEM | CATEGORY
The user picks a category and then the item list if filtered based on the previous selection. I now need to rearrange those columns are add another one, making it the 1st tier selection as follows:
LOCATION | CATEGORY | ITEM ID | ITEM
Just rearranging the columns alone breaks my code. On top of that I need to add the Location combobox, which would filter the Categories, which in turn filter the Items.
This is the code which handles the CATEGORY and ITEM list:
Private Sub cmbEquipCategory_Change()
Dim sh As Worksheet
Dim lastBlankRow As Long
Me.cmbEquipment.Clear
Set sh = Sheets("Equipment_List")
lastBlankRow = sh.Cells(Rows.Count, 3).End(xlUp).Row
For i = 2 To lastBlankRow
If sh.Cells(i, 3) = Me.cmbEquipCategory.value Then
Me.cmbEquipment.AddItem sh.Cells(i, 2)
End If
Next i
End Sub
It is my impression that I need to alter this code to draw data from columns 2 and 4 (it currently does so from 3 and 2) and write another almost identical block of code which handles LOCATION and CATEGORY. Any advice, resources or help would be greatly appreciated. Thanks!
The way I do this is to used named ranges. So selecting your ITEM ID would lead to one of several ITEM ranges (I name them according to the ITEM ID options) which would lead to one of several CATEGORY ranges (I name these according to the ITEM options). The more options you have the more ranges you need. Named ranges aren't broken by adding in columns.

Visual Studio 2012 - Coded UI Test Builder: Assertion Formula?

While automating testing of a website shopping experience, I am attempting to verify that the subtotal, total, and tax are calculating properly. Since the price and/or tax will change in the future, I cannot simply assert the actual price value inside the control. Instead, I would need to build a calculation based upon the controls themselves and assert that quantity multiplied by individual price for each item added together equals the subtotal, and so on.
For example, say my controls for each are named such (control names are in asterisks):
Quantity = *UIItem2Cell*
(InnerText has a Value of 2)
Individual Price = *UIItem249Pane*
(DisplayText has a value of 2.49)
Individual Product Total (price x qty) = *UIItem498Pane*
(InnerText has a Value of 4.98)
Instead of validating the values are the actual numbers, can I write an assertion formula using the identifiers as variables?
Keep in mind, I am using the Coded UI Test Builder rather than writing the code outright.
If the Individual Product Total InnerText assertion comparator is AreEqual, can the Comparison Value be something like:
UIItem2Cell-InnerText * UIItem249Pane-DisplayText
A. Is this sort of formula possible?
B. If so, how do I write it?
(Please forgive me, as I am very green when it comes to this.)
You most certainly can. First off in your app itself it would be greatly useful to use IDs on your controls so you can match on just that criteria. that way your not using calculated values for search criteria.
Now as is in your question you will need to pull those values from the cells, calculate the Value and use it in your Search Criteria
// I'd recommend trimming text values:
// depending on how tables and such are rendered you'll have extra white-space characters
var firstValue = Double.Parse(UIItem2Cell.InnerText.Trim());
var secondValue = Double.Parse(UIItem249Pane.DisplayText.Trim());
var calculatedValue = string.Format("{0,N2}%", firstValue * secondValue);
// assuming your in a web app
var totalDiv = new HtmlDiv(currentHtmlDoc);
totalDiv.SearchProperties.Add(new PropertyExpression(HtmlDiv.PropertyNames.InnerText, calculatedValue, PropertyExpressionOperator.Contains));
Assert.IsTrue(totalDiv.TryFind());
SringAssert.Contains(totalDiv.InnerText,calculatedValue);

Create comma-delimited values in Excel (using PivotTable)?

Is there a way to generate comma-delimited values in Excel (optimally using a PivotTable)? Consider the following data:
Object Color
foo Red
foo Blue
bar Red
bar Blue
bar Green
baz Yellow
I'd like to get a table like the following:
Object Count of Color Colors
foo 2 Red,Blue
bar 3 Red,Blue,Green
baz 1 Yellow
Is this possible in Excel? The data is coming from a SQL query, so I could write a UDF with a recursive CTE to calculate, but this was for a single ad-hoc query, and I wanted a quick-and-dirty way to get the denormalized data. In the end, it's probably taken longer to post this than to write the UDF, but...
Here's a much simpler answer, adapted from this superuser answer (HT to #yioann for pointing it out and #F106dart for the original):
Assuming the data is in columns A (Category) and B (Value):
Create a new column (C), and name it "Values". Use this formula, starting in cell C2 and copying all the way down: =IF(A2=A1, C1&","&B2, B2)
Create a second new column (D), and name it "Count". Use this formula, starting in cell D2, and copying all the way down: =IF(A2=A1, D1+1, 1)
Create a third new column (E), and name it "Last Line?". Use this fomula, starting in cell E2, and copying all of the way down: =A2<>A3
You can now hide column B (Value) and filter column E (Last Line?) for only the TRUE values.
In summary:
A B C D E
+--------- ----- ----------------------- ------------------- ----------
1| Category Value Values Count Last Line?
2| foo Red =IF(A2=A1,C1&","&B2,B2) =IF(A2=A1, D1+1, 1) =A2<>A3
3| foo Blue =IF(A3=A2,C2&","&B3,B3) =IF(A3=A2, D2+1, 1) =A3<>A2
etc.
Yes, you would be much better off using the tools of whatever RDBMS you're running (MS SQL, MySQL, etc.).
Such a pivot table is possible in Excel. But, only if you write a cumbersome VBA module -- which I don't recommend.
However, the task is simpler in MS Access -- which usually comes bundled with Excel. Microsoft makes it "easy" to link Access and Excel and to use the former to run queries on the latter.
So, given the spreadsheet cells as stated:
For best results, sort the table by Object and then by Color.
Make sure the spreadsheet is saved.
Open up MS Access.
Select File --> Open   (CtrlO)
Under Files of type, select Microsoft Excel
Navigate to and choose your existing spreadsheet.
Choose the worksheet or named range that contains your table.
Give the linked table the name MyPivot.
Open the Visual Basic Editor... Tools --> Macro --> Visual Basic Editor (AltF11)
Insert a module and paste in this UDF:
'Concat returns a comma-seperated list of items
Public Function Concat (CategoryCol As String, _
ItemCol As String) As String
Static LastCategory As String
Static ItemList As String
If CategoryCol = LastCategory Then
ItemList = ItemList & ", " & ItemCol
Else
LastCategory = CategoryCol
ItemList = ItemCol
End If
Concat = ItemList
End Function
Save the project and close the VB editor
Under Queries, Create a new query in design view.
Switch to the SQL View.
Paste in this SQL:
SELECT
Object,
COUNT (Color) AS [Count of Color],
LAST (Concat (Object, Color)) AS [List 'O Colors]
FROM
MyPivot
GROUP BY
Object
Run the query (Press the red exclamation mark or just select the Datasheet View).
Voilà, done in 15 easy steps!   ;)
Results:
Object Count of Color List 'O Colors
bar 3 Blue, Green, Red
baz 1 Yellow
foo 2 Blue, Red
An even easier way is to add the data to the data model when you create the pivot table and then use a "measure" (called "Colours") as follows:
=CONCATENATEX(Table1,[Color],", ")
Then add the "Colours" field to the values portion of the pivot.

Resources