# \[bug-15134\]Ignition 8 SFC Scope to Project Scripts

**URL:** <https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [July 12, 2019, 6:53pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526 "2019-07-12T18:53:07Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [July 12, 2019, 6:53pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/1 "2019-07-12T18:53:07Z")

</div>

Hello,

I’m struggling to get the scripting scope figured out, particularly as it relates to SFCs and scripts in a project. Currently I have a package I’ve put down in …\user-lib\pylib\<my package\> on the Ignition server, but would prefer to move the package to Project Library.

The issue I’m having is if I have an SFC in a project and add the script to the Project Library, I’m not able to make an import/reference work from the SFC to modules in the package.

For example if in the Project Library I have a package myPackage and maybe subpackage mySubPackage with various modules … nothing like myPackage.mySubPackage. works.

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [July 22, 2019, 8:35am UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/2 "2019-07-22T08:35:37Z")

</div>

Paul Scott’s post [Ignition 8 Tag Event Script](http://forum.inductiveautomation.com/t/ignition-8-tag-event-script/24602) helped me resolve the issue. While Paul didn’t address an SFC specifically a couple key phrases helped me understand … basically since an SFC is gateway scoped, getting access to the project script isn’t going to happen, except via “Gateway Scripting Project” project setting.

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 22, 2019, 3:43pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/3 "2019-07-22T15:43:12Z")

</div>

Hey, it looks like we missed this one.

Something doesn’t sound right about this.

SFCs belong to a project and should be able to access the project scripts available to that project. The Gateway Scripting Project is really only relevant for things like tags, which don’t belong to any project.

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [July 22, 2019, 8:45pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/4 "2019-07-22T20:45:26Z")

</div>

Hi Keven,

I created a simple SFC that opens a logger and calls testScript.doSomething() printing to the log the return value, here is the script:

```auto
def doSomething():
	return "This is something"

```

Regardless if I

```auto
import testScript
# Or
from . import testScript

# Or simply use full path
testScript.doSomething()

```

I also tried various other namespaces such as project…, or myProject… and other variations but the end result is along the lines of no module named testScript, no module named null, global name ‘testScript’ is not defined, etc.

Probably something simple, but I’m missing what it is.

Running version 8.02

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 22, 2019, 8:47pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/5 "2019-07-22T20:47:56Z")

</div>

Is the script in the same project as the SFC? Or if in a parent project, has the script’s module been overridden? Consider logging `str(dir())` to see what local variables are present.

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [July 25, 2019, 11:54pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/6 "2019-07-25T23:54:14Z")

</div>

All in the same project, here is an image:

![Ignition_Project](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f0b30a6cd6a8028ce7b0baa5474f11602452e472.png)

Any attempt in the SFC, which is nothing more then (Entry, Action, End) with the Action attempting to reference testScript (import testScript, or testScript.\<some\_method\>) results in the SFC aborting instead of making a clean exit.

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [August 10, 2019, 5:45pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/8 "2019-08-10T17:45:08Z")

</div>

I thought this was resolved in 8.03, turns out the offending line of code was commented out. Appears SFC in a project still cannot access script in the same project with 8.03.

Interesting though, if I create a timer even in Gateway Events in the same project, no problem getting to the project script. The SFC appears not to “scope in” the project itself.

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![joe.hammond](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@joe.hammond](https://forum.inductiveautomation.com/u/joe.hammond)\
**Post date:** [November 24, 2019, 10:25pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/9 "2019-11-24T22:25:39Z")

</div>

I tried calling a REST http call from within the SFC and could never get it to execute the function. One post said it was a bug in version 8.x and that I should place all scripts in the project library and call them, I tried this and I run into the same thing you show here. The SFC onStart script cannot see the Project Library scripts. I can’t seem to win here. Did you ever get a resolution?

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [December 2, 2019, 5:38pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/10 "2019-12-02T17:38:12Z")

</div>

Hi Joe,

No resolution last time I checked. I was on a support call with Inductive and the person I was working with made a quick project and saw the issue. He was going to submit the issue as he thought it should work as well. Of course there maybe some good reasons it doesn’t work or is difficult to make work, but I’ve not heard one way or the other as of yet.

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [December 16, 2019, 4:14pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/11 "2019-12-16T16:14:57Z")

</div>

Hi Joe,

I confirmed that 8.0.6 didn’t resolve the issue either.

-Rick

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 16, 2019, 4:19pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/12 "2019-12-16T16:19:32Z")

</div>

It’s a medium priority issue on our backlog, but hasn’t been assigned to any actual development team. I just gave the priority a kick, which should help a bit. We’ll update this thread when there’s progress.

---

<div class="post-metadata">

**Author:** ![cmorales](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@cmorales](https://forum.inductiveautomation.com/u/cmorales)\
**Post date:** [May 29, 2020, 12:27am UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/13 "2020-05-29T00:27:49Z")

</div>

Hi PGriffith,

Any updates on this topic?

Thanks,  
Carlos

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 29, 2020, 2:58pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/14 "2020-05-29T14:58:29Z")

</div>

Nope, nothing yet.

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [June 3, 2020, 9:06pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/15 "2020-06-03T21:06:55Z")

</div>

Any estimate as to when this may occur? Would be nice to be able to version everything in one project instead of having to consider script scatted elsewhere, well, okay, one more place, but that is still elsewhere 🙂

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [July 28, 2020, 2:36am UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/16 "2020-07-28T02:36:35Z")

</div>

So I think the current version is well passed the point of needing a toggle to turn this off/on in a project without causing a breaking change.

Sure would be nice to have script in the same project as the SFC … that the SFC can reference. Currently we are forced to share global so checking into the repo means a build signal is triggered for something that doesn’t need to be. Had the script change been local to the project then only that project needs to be deployed. As of now code management a little more tedious but even more when it’s time to use pipeline/workflows they can’t be fully automated otherwise more change are deployed than required.

Any estimate as to when we might see this come to fruition?

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![rttwge](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rttwge](https://forum.inductiveautomation.com/u/rttwge)\
**Post date:** [June 14, 2021, 3:39pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/17 "2021-06-14T15:39:06Z")

</div>

I installed 8.1.4 and tested a project that has been in use through most all the 8.0.x versions up through 8.1.1. After the installation we noticed an SFC wasn’t working.

The SFC referenced script that was in the designated “global” project. No longer could the SFC see the script so I though for a test I would copy the script into the same project as the SFC … and to my surprise it worked!

I’m glad to see an SFC can now use script within the same project, but I’m surprised it could no longer use the script in the “global” project, any idea why that may be?

Thanks,

Rick

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 14, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/bug-15134-ignition-8-sfc-scope-to-project-scripts/26526/18 "2021-06-14T15:47:22Z")

</div>

> [@rttwge](#):
>
> I’m glad to see an SFC can now use script within the same project, but I’m surprised it could no longer use the script in the “global” project, any idea why that may be?

SFCs were mistakenly executing scripts using the context of whatever is designated as the "Gateway Scripting Project", which is the "global" project on an upgrade.

This was recently fixed so that it correctly uses the context of its project (and any parent projects it may have).

edit: fixed in 8.1.2 with this release note:

> SFC Python scripts and expressions can now reference Project Scripts.

Perhaps it should have also mentioned that the previous context would no longer be available.
