# SFC Instance with key parameter

**URL:** <https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678>\
**Category:** Ignition\
**Created:** [February 14, 2017, 7:13pm UTC](https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678 "2017-02-14T19:13:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![palmer\_md](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@palmer\_md](https://forum.inductiveautomation.com/u/palmer_md)\
**Post date:** [February 14, 2017, 7:13pm UTC](https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678/1 "2017-02-14T19:13:44Z")

</div>

I have an SFC that also includes a key parameter. I would like to be able to only have one instance of this running at a time (same key parameter). I’m trying to figure out how to detect if an instance is running with the same key. How can I tell if one is running? I’d like to disable the start button that runs the startChart command if it is already running another instance with the same key parameter.

---

<div class="post-metadata">

**Author:** ![adam.morales](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/adam.morales/32/3405_2.png) [@adam.morales](https://forum.inductiveautomation.com/u/adam.morales)\
**Post date:** [February 14, 2017, 7:20pm UTC](https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678/2 "2017-02-14T19:20:07Z")

</div>

I think that this function should help you out with that:  
[docs.inductiveautomation.com/di … ningCharts](https://docs.inductiveautomation.com/display/DOC79/system.sfc.getRunningCharts)

This function will return a dataset with the columns instanceId, chartPath, startDate, startedBy, chartState, keyParamName, keyParamValue

---

<div class="post-metadata">

**Author:** ![palmer\_md](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@palmer\_md](https://forum.inductiveautomation.com/u/palmer_md)\
**Post date:** [February 15, 2017, 12:54am UTC](https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678/3 "2017-02-15T00:54:56Z")

</div>

[quote=“adam.morales”]I think that this function should help you out with that:  
[docs.inductiveautomation.com/di … ningCharts](https://docs.inductiveautomation.com/display/DOC79/system.sfc.getRunningCharts)

This function will return a dataset with the columns instanceId, chartPath, startDate, startedBy, chartState, keyParamName, keyParamValue[/quote]

This works. Thank you very much. I’m looking to see if there is a chart that has the same keyParamValue, and it works great. Interesting when i look at the dataset and look at the chartPath (and compare to a string) that works fine, but when looking at chartState, and compare to “Running” it never seems to work. I’ve tried several ways, and even though in a table it shows up as Running, when I do a compare to the value it is always false. also tried RUNNING and running. I skipped this for now, since it is only a problem for a few seconds after the SFC stops. It sits at stopped for a few seconds before the instance disappears from the list of charts. I’ll just have to make sure that they can’t attempt to start right after the sequence ends.

---

<div class="post-metadata">

**Author:** ![adam.morales](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/adam.morales/32/3405_2.png) [@adam.morales](https://forum.inductiveautomation.com/u/adam.morales)\
**Post date:** [February 15, 2017, 4:55pm UTC](https://forum.inductiveautomation.com/t/sfc-instance-with-key-parameter/12678/4 "2017-02-15T16:55:18Z")

</div>

The chartState is a ChartStateEnum object, rather than a string. But you can obtain a stringified version by calling its toString() method. For example:

[code]ds = system.sfc.getRunningCharts()

for row in range(ds.rowCount):  
state = ds.getValueAt(row,‘chartState’)  
print state.toString() == ‘Running’[/code]
