Need some help with learning how to set a token for time in a dashboard in eval that will populate the date user selects. I have set my time token already and would like to pass my time token to | eval EndingSpiral=strpTime("$tokEarliest$", "%Y-%m-%d %H:%M:%S"), but the dates are not populating. Anyone know what I'm doing wrong or not doing? I would appreciate your help.
This is how I set my time token earlier in the xml code:
<fieldset submitButton="false">
<input type="time" token="time_range" searchWhenChanged="true">
<label>Select Time Range</label>
<default>
<earliest>-7d#h</earliest>
<latest>now</latest>
</default>
<change>
</change>
</input>
<query>
| eval EndingSpiral=strpTime("$tokEarliest$", "%Y-%m-%d %H:%M:%S"), Spiraling= strpTime(relevantSprialTime, "%Y-%m-%d %H:%M:%S.%q")
| eval Start = strptime(SomeTime,"%Y-%m-%d %H:%M:%S.%q"), End=strptime(SomeOtherTime,"%Y-%m-%d %H:%M:%S.%6N")
<earliest>$time_range.earliest$</earliest>
<latest>$time_range.latest$</latest><progress>
<eval token="tokEarliest">strptime($time_range.earliest$,"%Y-%m-%d %H:%M:%S")</eval>
<eval token="tokLatest">strptime($time_range.latest$,"%Y-%m-%d %H:%M:%S")</eval>
</progress>
Time tokens are not strings so they shouldn't be used as arguments to strptime. It also does not make sense to parse the result of strptime. You'll get a null result in each case. Just assign $time_range.earliest$ to EndingSpiral.
Related
I have a eval on a dashboard that used to work but it stopped and I havent been able to figure out why.
On the dashboard im taking the _time and turning it into a human readable string using strftime(_time, "%m/%d/%Y %H:%M:%S %Z") and that works great. The problem comes in when I try to convert it back later for making a link to a search.
For example:
<eval token="endTimestamp">relative_time(strptime($row.Timestamp$, "%m/%d/%Y %H:%M:%S %Z"), "+30m")</eval>
Used to work and return the unix time that I added 30m to, but now strptime just returns NaN but this is the right format. I've checked out all the Splunk docs and everything looks right but it still is broke.
Any idea what I could be doing wrong?
Here is the snippet from my field row im making:
<condition field="Search">
<eval token="startTimestamp">$row.Timestamp$</eval>
<eval token="endTimestamp">relative_time(strptime($row.Timestamp$, "%m/%d/%Y %H:%M:%S %Z"), "+30m")</eval>
<eval token="corKey">$row.Correlation Key$</eval>
<link target="_blank">search?q=(index=### OR index=###) earliest=$startTimestamp$ latest=$endTimestamp$ correlationKey=$corKey$</link>
</condition>
I have taken out everything but the $row.Timestamp$ and that returns something like 10/03/2021 07:41:27 PDT which is the format that I put into it, I just cant do the reverse. I have copied and pasted the format from the strftime and still no luck converting it back so I can do math on it.
Any suggestions?
I don't think it's anything you're doing wrong... but it does seem that strptime/strftime in the dashboard evals don't seem to like %Z for whatever reason. (My Splunk Cloud stack is on version 8.2.2107.1 )
Doing the roundtrip from epoch to string and back within SPL itself seems to work fine... it's just the (javascript driven) dashboard side that doesn't seem to work quite right with timezone abbreviations.
relative_time from an epoch value works fine... and str[pf]time using UTC offsets with %z format also seems to work (which those could be workarounds for you)
I threw together a quick test dashboard to illustrate such things with the variations in formats to see differences... If you (or someone from your company) is on a current support entitlement, I would log a case for this. (I don't think I see anything related in the published known issues at least).
<dashboard version="1.1">
<label>Teddybear Time Drilldown Test</label>
<row>
<panel>
<table>
<search>
<query>
| makeresults
| eval epoch="1633272087", format=mvappend("%m/%d/%Y %H:%M:%S %Z","%m/%d/%Y %H:%M:%S %z","%m/%d/%Y %H:%M:%S"), Search="Go This Row", Reset="Clear"
| fields - _time
| mvexpand format
| eval Timestamp=strftime(epoch,format), roundtrip=strptime(Timestamp,format)
| table Search, Reset, *
</query>
<earliest>-1s</earliest>
<latest>now</latest>
</search>
<option name="drilldown">cell</option>
<option name="rowNumbers">true</option>
<drilldown>
<condition field="Search">
<eval token="timestamp">$row.Timestamp$</eval>
<eval token="strptime">strptime($row.Timestamp$, $row.format$)</eval>
<eval token="strftime">strftime($row.epoch$, $row.format$)</eval>
<eval token="relative_time">relative_time($row.epoch$,"-30m")</eval>
</condition>
<condition field="Reset">
<unset token="timestamp"/> <unset token="strptime"/> <unset token="strftime"/> <unset token="relative_time"/>
</condition>
</drilldown>
</table>
</panel>
</row>
<row>
<panel>
<title>timestamp</title>
<html>
<h2>$timestamp|s$</h2>
</html>
</panel>
<panel>
<title>strptime</title>
<html>
<h2>$strptime|s$</h2>
</html>
</panel>
<panel>
<title>strftime</title>
<html>
<h2>$strftime|s$</h2>
</html>
</panel>
<panel>
<title>relative_time</title>
<html>
<h2>$relative_time|s$</h2>
</html>
</panel>
</row>
</dashboard>
I have the version of UiPath Studio Pro 2020.10.6, and I used Chrome.
I can't find the common Selector on two pages:
First case - failed one
Second case - great one
The selectors offered by the tool are the following:
Case 1:
<html app='chrome.exe' title='Sephora X Coach - Palette de fards à paupières Rexy de SEPHORA COLLECTION ≡ SEPHORA' />
<webctrl id='add-to-cart' tag='BUTTON' type='submit' />
Case 2:
<html app='chrome.exe' title='Kit maquillage des yeux de SEPHORA COLLECTION ≡ SEPHORA' />
<webctrl id='add-all-to-cart' tag='BUTTON' type='submit' />
Removing the title tag does not solve the problem.
The use of wild-cards does not work.
I looked via the "Fuzzy Search":https://docs.uipath.com/studio/docs/fuzzy-search-capabilities
I did the test in Python of the script of the page for the first case: https://www.datacamp.com/community/tutorials/fuzzy-string-python
The result is like in the picture above:
But it's not working too for the first case, since I put the level at 0.1
<html app='chrome.exe' title='"+SelectorString+ "' matching:title='fuzzy' fuzzylevel:title='0.3' /><webctrl id='add-all-to-cart' tag='BUTTON' type='submit' />
with
SelectorString = "Sephora X Coach"
I have no more idea, is the fact that in my first case the button is in a form (when looking at the code of the HTML page) and not in the second case?
Thank you in advance for your help.
I find the solution, I change the selector like that:
<html app='chrome.exe' />
<webctrl id='add[-all]*-to-cart' matching:id='regex' tag='BUTTON' type='submit' />
Even the user has entered only 1 number, the validation is not working, I think the problem that occurs with maskChar value of Inputmask.
<Field
component={NumberField}
name="phone"
mask="+1 (999) 999-9999"
placeholder="Phone"
/>```
```
<InputMask
mask={mask}
maskChar={maskChar}
{...input}
value={toUpper && input.value.trim()}
label={label}
onFocus={() => isActive(true)}
onBlur={() => isActive(false)}
placeholder={active ? '' : thePlaceholder}
aria-label={label}
type={type}
required={required}
/>
`
``
If you have no problem with new NPM package this one looks good:
https://www.npmjs.com/package/validator
or this one:
https://catamphetamine.github.io/react-phone-number-input/
https://github.com/catamphetamine/react-phone-number-input
or you can check this SO answer
I rarely use xpath() but when I do I keep tripping myself up on interpreting content of Nokogiri::Nodesets and believe I now know where I have always gone wrong.
Simply put when I do a 'puts NodeSet' I have always assumed that I could search the Nodeset based on the returned XML. But the first tag returned does not appear to actually part of the node XML.
'puts n1' returns XML that has a SPAN as the first element of the XML, but if I then do an search n1.xpath('SPAN') or n1.xpath('SPAN/DIV') no nodes are found. n1.xpath('DIV') returns the output I expect and proves no SPAN tag in the XML.
The only way I can logically explain this to myself is if assume that the first xml tag of a 'puts node' is the "Node Name" and not part of the node XML. This works for me going forward but am I missing something that is going to bite me elsewhere.
CODE:
docxml = Nokogiri::XML(<<EOT)
<DIV><SPAN><DIV id='1'><H1>-H1-</H1><h1>-h1-</h1></DIV>
<DIV id='2'><H2>-H2-</H2> <h2>-h2-</h2></DIV>
<DIV id='3'><H3>-H3-</H3><h3>-h3-</h3></DIV>
</SPAN></DIV>
EOT
n0 = docxml.xpath('DIV')
n1 = n0.xpath('SPAN')
n2 = n1.xpath('DIV')
n3 = n2.xpath('*')
n4 = n3.xpath('*')
puts "n1:xpath('SPAN'): \n#{n1.xpath('SPAN')}\n#{'^'*80} \nn1 XML:\n#{n1}\n#{'^'*80}\
\nn1:inspect \n#{n1.inspect}\n#{'^'*80}\n"
OUTPUT:
=begin
n1:xpath('SPAN'):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
n1 XML:
<SPAN>
<DIV id="1"> <H1>-H1-</H1> <h1>-h1-</h1> </DIV>
<DIV id="2"> <H2>-H2-</H2> <h2>-h2-</h2> </DIV>
<DIV id="3"> <H3>-H3-</H3> <h3>-h3-</h3> </DIV>
</SPAN>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
n1:inspect
[#<Nokogiri::XML::Element:0x1c10964 name="SPAN"
children=[
#<Nokogiri::XML::Element:0x1c10820 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x18fff90 name="id" value="1">]
children=[#<Nokogiri::XML::Element:0x1c1064c name="H1" children=[#<Nokogiri::XML::Text:0x1c1ffe8 "-H1-">]>,
#<Nokogiri::XML::Element:0x1c10604 name="h1" children=[#<Nokogiri::XML::Text:0x1c1fdcc "-h1-">]>
]>,
#<Nokogiri::XML::Element:0x1c107d8 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x1c1fc10 name="id" value="2">]
children=[#<Nokogiri::XML::Element:0x1c105bc name="H2" children=[#<Nokogiri::XML::Text:0x1c1f874 "-H2-">]>,
#<Nokogiri::XML::Text:0x1c1f778 " ">,
#<Nokogiri::XML::Element:0x1c10574 name="h2" children=[#<Nokogiri::XML::Text:0x1c1f5f8 "-h2-">]
>]>,
#<Nokogiri::XML::Element:0x1c10790 name="DIV" attributes=[#<Nokogiri::XML::Attr:0x1c1f43c name="id" value="3">]
children=[#<Nokogiri::XML::Element:0x1c1052c name="H3" children=[#<Nokogiri::XML::Text:0x1c1f0a0 "-H3-">]>,
#<Nokogiri::XML::Element:0x1c104e4 name="h3" children=[#<Nokogiri::XML::Text:0x1c1ee90 "-h3-">]
>]
>]
>]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
=end
Now that I have had some sleep this works for me.
'nodeset = xpath(tag1/tag2)' returns a 'nodeset' containing member node 'tag2'
'puts nodeset' displays the 'tag2' node member
'nodeset.xpath('*')' returns the content of 'tag2
'nodeset.xpath('tag2')' invalid as 'tag2' is not part of the content of 'tag2'
I'm trying to extract specific data from a complex XML data set stored in a CLOB field in a commercial app. I cannot change the XML format (namespace, etc), I cannot change the CLOB to XMLType.
The xml data looks like:
<?xml version="1.0" encoding="utf-8"?>
<Calculation>
<ProcessUnitModelScenario Id="1265319" EntityId="10030" EntityName="Chaco Plant" ProcessUnitId="10225" ProcessUnitName="Turbine - Unit 37" EmissionModelId="10000" EmissionModelName="Emissions" ScenarioId="10053" ScenarioName="GHG_Comb_Run_Time" EffectiveDate="1/1/2012 12:00:00 AM" EndDate="2/1/2012 12:00:00 AM" ActiveDate="1/1/2008 12:00:00 AM" ProductionUnitId="10031" ProductionUnitName="Default Production Unit - Month" ProductionScheduleId="13541" OperatingPercentage="100" LinkLevel="1">
<EmissionModel Id="10935" EffectiveDate="1/1/2012 12:00:00 AM" EndDate="2/1/2012 12:00:00 AM">
<EmissionModelMaterial Id="13250" OutputType="Air Emissions" OutputTypeId="1" Media="Vapor" MediaName="Air" MaterialId="83" EquationId="10096" EquationName="GHG Combustion: Run time" EquationUnit="lb/hr" EquationUnitName="lb/hr" EquationBaseUnit="lb/hr" EquationBaseUnitName="lb/hr" SpeciationOption="StandardSpeciation" SpeciationOptionName="Standard Speciation" UseComponentVaporPressureMethods="False" VaporPressureOptionName="Material's vapor pressure methods">
<Material Id="83" Name="Methane" EffectiveId="10082" EffectiveDate="1/1/1990 12:00:00 AM" ComponentBasis="Vapor" MolecularWeight="16.043" LiquidDensity="1.34687732957939" VaporPressureMethod="Riedels" RiedelA="39.205" RiedelB="-1324.4" RiedelC="-3.4366" RiedelD="3.1E-05" RiedelE="2" UseDefinedComposition="False">
<CalculationPeriod StartDate="1/1/2012 12:00:00 AM" EndDate="2/1/2012 12:00:00 AM">
<EquationVariable Id="11079" Name="HeatRating" Order="10" BaseUnit="BTU/sec" EquationUnit="MMBtu/hr" Type="System" TypeName="System Variable" SystemCalculationType="ProcessUnitProperty" SystemCalculationName="Process Unit Property" SystemParameterProcessPropertyId="10005" SystemParameterModelOutputTypeId="1" TimeDependent="False" Value="116" EnteredValue="116" EnteredUnit="MMBtu/hr" />
<EquationVariable Id="11077" Name="GHGEF" Order="20" BaseUnit="lb/BTU" EquationUnit="kg/MMBTU" Type="GlobalEmissionFactor" TypeName="Global Emission Factor" TimeDependent="True" Value="0.001" EnteredValue="0.001" EnteredUnit="kg/MMBTU" />
<EquationVariable Id="11078" Name="RunHrs" Order="30" BaseUnit="hr" Type="Parameter" TypeName="Parameter" ParameterLevel="ProcessUnit" ParameterLevelName="Process Unit" ParameterId="10044" ParameterName="RunHrs - " TimeDependent="True" Value="612" EnteredValue="612" EnteredUnit="hr" />
<EquationVariable Id="11080" Name="kgtolb" Order="40" BaseUnit="lb" Type="GlobalConstant" TypeName="Global Constant" GlobalConstantId="10007" TimeDependent="False" Value="2.20462" />
<EquationVariable Id="11081" Name="OpHrs" Order="45" BaseUnit="hr" EquationUnit="hr" Type="System" TypeName="System Variable" SystemCalculationType="OperatingHours" SystemCalculationName="Operating Hours" TimeDependent="True" Value="744" />
<EquationVariable Id="11082" Name="EmissionRate" Order="46" BaseUnit="lb/hr" Type="FinalResult" TypeName="Final Expression" Formula="(HeatRating*GHGEF)*RunHrs*kgtolb/OpHrs" TimeDependent="True" Value="0.210363418064516" />
<Emission EffectiveDate="1/1/2012 12:00:00 AM" EndDate="2/1/2012 12:00:00 AM" BaseUnit="lb/hr" BaseUnitName="lb/hr" EmissionAmount="0.210363418064516" Unit="lb/hr" UnitName="lb/hr" ResultValue="0.210363418064516" LinkType="Unabated" LinkTypeName="" OperatingHours="744" EmissionMass="156.51038304" EmissionMassUnit="lb" MaterialId="83" EffectiveMaterialId="10082" MaterialName="Methane" MaterialEffectiveDate="1/1/1990 12:00:00 AM" />
</CalculationPeriod>
</Material>
<Material etc...>
</Material>
</EmissionModelMaterial>
<EmissionModelMaterial etc...>
</EmissionModelMaterial>
</EmissionModel>
<EmissionModel etc...>
</EmissionModel>
<ProcessUnitModelScenario etc...>
</ProcessUnitModelScenario>
</Calculation>
My need is to return certain attribute values from the elements for specified combination of [ProcessUnitModelScenario/#ProcessUnitId], [ProcessUnitModelScenario/#ScenarioId], and [Material/#Id].
The XML data is kept in the Air_Calc_Log table Verbose_Xml CLOB field.
In my PL/SQL I am (mis?)using the follow select:
SELECT
XMLType(l.verbose_xml).extract(
'for $scen in /Calculation/ProcessUnitModelScenario
where ($scen/#ScenarioId="10053")
return $scen/* ')
FROM air_calc_log l
WHERE l.vld_site_id = 10030 -- pVldSite
AND l.start_date = To_Date('01/01/2012','mm/dd/yyyy') -- pStartDate
AND l.End_Date = To_Date('04/01/2012','mm/dd/yyyy')
Whatever combination of XQuery/XPath using FLOWR syntax I use I always get the following error message:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: 'for $scen in /Calculation/ProcessUnitModelScenario
where ($scen/#ScenarioId="10053")
return $scen/* '
ORA-06512: at "SYS.XMLTYPE", line 111
Can someone help point out what I'm doing wrong?
Try it like this:
SELECT
XMLType(l.verbose_xml).extract(
'/Calculation/ProcessUnitModelScenario[#ScenarioId="10053"]')
FROM air_calc_log l
WHERE l.vld_site_id = 10030 -- pVldSite
AND l.start_date = To_Date('01/01/2012','mm/dd/yyyy') -- pStartDate
AND l.End_Date = To_Date('04/01/2012','mm/dd/yyyy')
Here is a fiddle (Note that I had to change your XML to make it well-formed)