<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Dynamically change part of code in Code stage in University Forum</title>
    <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85879#M1621</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;There is a MS Excel Extended asset on Digital Exchange providing Pivot Table related actions. I would suggest to see if that meets the requirements. Additionally the code can be further customized.&lt;BR /&gt;&lt;A href="https://digitalexchange.blueprism.com/dx/entry/9648/solution/ms-excel-vbo---extended" target="test_blank"&gt;https://digitalexchange.blueprism.com/dx/entry/9648/solution/ms-excel-vbo---extended&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Shashank Kumar&lt;BR /&gt;DX Integrations Partner Consultant&lt;BR /&gt;Blue Prism&lt;BR /&gt;Singapore&lt;BR /&gt;+6581326707&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Thu, 17 Sep 2020 13:30:00 GMT</pubDate>
    <dc:creator>shashank.kumar280</dc:creator>
    <dc:date>2020-09-17T13:30:00Z</dc:date>
    <item>
      <title>Dynamically change part of code in Code stage</title>
      <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85876#M1618</link>
      <description>&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a Code stage that creates Pivot Table in Excel. The first part of the code is general and the second part is there to describe how the Pivot Table should look like. I would like to be able to dynamically change the second part whenever I want to change the Pivot Table layout. How to do that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is my example. I would like to create the PART TWO in Process Studio and send it to Code Stage as a variable or something like that. Is there any way?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;CODE&gt;'PART ONE'
--------------
Dim rng as Object
Dim wb as Object = GetWorkbook(handle,workbookname)
Dim ws as Object = GetWorksheet(handle,workbookname,worksheetname,createifmissing)

sheetexists = ws IsNot Nothing
If sheetexists then ws.Activate()

rng = range

Dim PCache as object = wb.PivotCaches.Create(SourceType:=1, SourceData:= rng).CreatePivotTable(TableDestination:=ws.Range("B2"), TableName:="PivotTable1")

'PART TWO'
--------------
With ws.PivotTables("PivotTable1").PivotFields("Column1")
.Orientation = 1
.Position = 1
End With

with ws.PivotTables("PivotTable1").PivotFields("Column2")
.Orientation = 4
.Position = 1
.Function = -4112
.Caption = "Count of Column2"
End With​&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;to_mas_re&lt;BR /&gt;------------------------------</description>
      <pubDate>Wed, 16 Sep 2020 13:38:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85876#M1618</guid>
      <dc:creator>to_mas_re</dc:creator>
      <dc:date>2020-09-16T13:38:00Z</dc:date>
    </item>
    <item>
      <title>RE: Dynamically change part of code in Code stage</title>
      <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85877#M1619</link>
      <description>Hi &lt;A id="MainCopy_ctl08_ucMessageList_rptMessageList_ProfileImageDisplay_0_NameLink_0" biobubblekey="c49034f2-03e7-4dc9-bd54-e0ae5d4b4bd1" href="https://community.blueprism.com/network/profile?UserKey=c49034f2-03e7-4dc9-bd54-e0ae5d4b4bd1" target="_blank" rel="noopener"&gt;Tomas&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;You can have a input variable for the code stage whose value you will be able to access inside the code. Based on this variable you can have a If/else statement block and put the relevant code in the desired block.&lt;BR /&gt;&lt;BR /&gt;Sample code stage snapshot with If condition-&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32815.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32913i278538F0EF40E241/image-size/large?v=v2&amp;amp;px=999" role="button" title="32815.png" alt="32815.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32816.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32917iA4CDCB1FFC344E6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="32816.png" alt="32816.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Shashank Kumar&lt;BR /&gt;DX Integrations Partner Consultant&lt;BR /&gt;Blue Prism&lt;BR /&gt;Singapore&lt;BR /&gt;+6581326707&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Sep 2020 15:59:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85877#M1619</guid>
      <dc:creator>shashank.kumar280</dc:creator>
      <dc:date>2020-09-16T15:59:00Z</dc:date>
    </item>
    <item>
      <title>RE: Dynamically change part of code in Code stage</title>
      <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85878#M1620</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;thanks for response. Could you please further explain this approach? Maybe use my case as an example.&lt;BR /&gt;&lt;BR /&gt;My point is that I want developer to define everything about the Pivot Table in one code, that he can then send to this code stage and create the table. There is a lot of attributes to PivotFields that developer can define and cannot imagine to use If Else statement to cover all of them (or at least the most important).&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Tomas Rehak&lt;BR /&gt;RPA Developer&lt;BR /&gt;VUB Slovensko&lt;BR /&gt;Europe/Bratislava&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2020 11:23:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85878#M1620</guid>
      <dc:creator>to_mas_re</dc:creator>
      <dc:date>2020-09-17T11:23:00Z</dc:date>
    </item>
    <item>
      <title>RE: Dynamically change part of code in Code stage</title>
      <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85879#M1621</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;There is a MS Excel Extended asset on Digital Exchange providing Pivot Table related actions. I would suggest to see if that meets the requirements. Additionally the code can be further customized.&lt;BR /&gt;&lt;A href="https://digitalexchange.blueprism.com/dx/entry/9648/solution/ms-excel-vbo---extended" target="test_blank"&gt;https://digitalexchange.blueprism.com/dx/entry/9648/solution/ms-excel-vbo---extended&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Shashank Kumar&lt;BR /&gt;DX Integrations Partner Consultant&lt;BR /&gt;Blue Prism&lt;BR /&gt;Singapore&lt;BR /&gt;+6581326707&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2020 13:30:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85879#M1621</guid>
      <dc:creator>shashank.kumar280</dc:creator>
      <dc:date>2020-09-17T13:30:00Z</dc:date>
    </item>
    <item>
      <title>RE: Dynamically change part of code in Code stage</title>
      <link>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85880#M1622</link>
      <description>I am glad I could spent two days on something that already exists -_- Don't know how I was not able to find this before.&lt;BR /&gt;&lt;BR /&gt;BUT! Since I wanted to create general Action for creating Pivot Table, here is my solution (big thanks goes to sahil_raina_91 on rpaforum).&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Duplicate Action "Activate Worksheet" and change name (my name is "Create Pivot Table")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Change code stage. Add these lines and new input "range" (see img1 and img2):&lt;/SPAN&gt;&lt;BR /&gt;
&lt;DIV class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"&gt;
&lt;DIV class="bbCodeBlock-title"&gt;Code:&lt;/DIV&gt;
&lt;DIV class="bbCodeBlock-content" dir="ltr"&gt;&lt;CODE&gt;rng = range
Dim PCache as object = wb.PivotCaches.Create(SourceType:=1, SourceData:= rng).CreatePivotTable _
(TableDestination:=ws.Range("B2"), TableName:="PivotTable1")&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;SPAN&gt;3. Create Collection "PTStructure" with given fields (see img3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Loop through the Collection and create code stage with these lines:&lt;/SPAN&gt;&lt;BR /&gt;
&lt;DIV class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"&gt;
&lt;DIV class="bbCodeBlock-title"&gt;Code:&lt;/DIV&gt;
&lt;DIV class="bbCodeBlock-content" dir="ltr"&gt;&lt;CODE&gt;Dim wb as Object = GetWorkbook(handle,workbookname)
Dim ws as Object = GetWorksheet(handle,workbookname,worksheetname)

If Len(ToString(orientation))=0 Then Throw New Exception("Orientation is mandatory parameter")
If Len(ToString(position))=0 Then Throw New Exception("Position is mandatory parameter")

With ws.PivotTables(tablename).PivotFields(pivotfield)
.Orientation = orientation
.Position = position
If fnctn&amp;lt;&amp;gt;0 Then .Function = fnctn
If calculation&amp;lt;&amp;gt;0 Then .Calculation = calculation
If caption&amp;lt;&amp;gt;"" Then .Caption = caption
End With&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;SPAN&gt;This is so far the best I can do. I believe there are few things that can be implemented better, but ... whatever.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this was helpfull.&lt;/SPAN&gt;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32821.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32920i478FE8C59D960617/image-size/large?v=v2&amp;amp;px=999" role="button" title="32821.png" alt="32821.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32822.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32923iE982208CB44D3144/image-size/large?v=v2&amp;amp;px=999" role="button" title="32822.png" alt="32822.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32823.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32922i08F79D131B34EED7/image-size/large?v=v2&amp;amp;px=999" role="button" title="32823.png" alt="32823.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32824.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32924iBB71612983708222/image-size/large?v=v2&amp;amp;px=999" role="button" title="32824.png" alt="32824.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32825.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32927iC0318B20DBD99D1D/image-size/large?v=v2&amp;amp;px=999" role="button" title="32825.png" alt="32825.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="32826.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/32928i9E46788C8928359E/image-size/large?v=v2&amp;amp;px=999" role="button" title="32826.png" alt="32826.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Tomas Rehak&lt;BR /&gt;RPA Developer&lt;BR /&gt;VUB Slovensko&lt;BR /&gt;Europe/Bratislava&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2020 13:46:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/University-Forum/Dynamically-change-part-of-code-in-Code-stage/m-p/85880#M1622</guid>
      <dc:creator>to_mas_re</dc:creator>
      <dc:date>2020-09-17T13:46:00Z</dc:date>
    </item>
  </channel>
</rss>

