# Script format error?

**URL:** <https://forum.inductiveautomation.com/t/script-format-error/109493>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 7, 2025, 5:21pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493 "2025-08-07T17:21:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaerrydairy](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chaerrydairy](https://forum.inductiveautomation.com/u/chaerrydairy)\
**Post date:** [August 7, 2025, 5:21pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/1 "2025-08-07T17:21:44Z")

</div>

![{C1646DAB-E4DD-46FB-BDA0-2E9EA42FB80E}](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/7/5790d33d641e5b4c707003c870923bbcbb6d166a.png)  
why is there a red underline here? No matter how much I try to redo it it shows that red underline. The format is correct, I just pressed tab once and everything should be good but this red underline does not go away, is this something that happens some times?

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [August 7, 2025, 5:25pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/2 "2025-08-07T17:25:52Z")

</div>

We can’t tell without seeing the rest of the script, but it’s probably an indentation error (or you’re missing a `:` at the end of an expression–something like that). There was a similar thread recently, you might try this:

> [@Indentation error in scripts](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/4):
>
> Right click in the editor space -\> appearance -\> whitespace. This should allow you to determine if you have mixed spaces and tabs. Also make sure you aren't missing any colons or brackets.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 7, 2025, 5:27pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/3 "2025-08-07T17:27:28Z")

</div>

Also, when posting scripts, post them as preformatted text. It helps speed up the troubleshooting process by others, see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) .

---

<div class="post-metadata">

**Author:** ![chaerrydairy](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chaerrydairy](https://forum.inductiveautomation.com/u/chaerrydairy)\
**Post date:** [August 7, 2025, 5:29pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/4 "2025-08-07T17:29:58Z")

</div>

```python
	assetID = self.parent.parent.getChild("AssetIDDetails").getChild("IDDisplay").props.text	
	assetName = self.parent.parent.getChild("AssetNameDetails").getChild("NameDisplay").props.text
	lineID = self.parent.parent.getChild("LineIDDetails").getChild("IDDisplay").props.text
	lineName = self.parent.parent.getChild("LineNameDetails").getChild("NameDropdown").props.value
	locationID = self.parent.parent.getChild("LocationDetails").getChild("LocationDropdown").props.value
	categoryID = self.parent.parent.getChild("CategoryDetails").getChild("CategoryDropdown").props.value
	role_name= self.parent.parent.getChild("RoleAndWorkcenterContainer").getChild("RoleDropdown").props.value
	andonDisplay = self.parent.parent.getChild("AndonDisplayDetails").getChild("AndonDisplay").props.text
	roleID = 0
	if role_name == 'Primary':
		roleID = 1
	else:
		roleID = 2
	modified = self.session.custom.clockNumber
	
	try:
	    IDAllowed = False
	
	    if assetID == '':
	        # Auto-generate Asset ID
	        maxIDDataset = system.db.runNamedQuery('Assets/GetMaxID')
	        if maxIDDataset.rowCount > 0:
	            assetID = int(maxIDDataset[0]['Asset_ID']) + 1
	        IDAllowed = True
	    else:
	        # Check if custom Asset ID already exists
	        check = system.db.runNamedQuery('Assets/CheckExist', {'assetID': assetID})
	        if check.rowCount > 0:
	            raise Exception("ID already exists, try another ID")
	        else:
	            IDAllowed = True
		
		system.perspective.print("Now create asset)
		
		# --- Create asset if ID is allowed ---
		if IDAllowed:
	        parameters = {
	            'assetID': assetID,
	            'assetName': assetName,
	            'lineID': lineID,
	            'roleID': 1 if role_name == 'Primary' else 2,
	            'modifiedBy': modified,
	            'andonDisplay': andonDisplay
	        }
	
	        result = system.db.runNamedQuery('Assets/CreateAsset', parameters)
	
	        if result:
				# log change in Change_Log DB table
				# retrieve group ID given selected group name in dropdown menu
				# categoryID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column2").getChild("Category").getChild("CategoryDropdown").props.value	
				categories = {1: 'Molding', 2: 'Paint', 3: 'Assembly', 4: 'Warehouse'}
				category = categories[categoryID]
				
				# Location from dropdown 
				#locationID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column1").getChild("Location").getChild("LocationDropdown").props.value	
				location = locationID
				
				controller = int(self.session.custom.clockNumber)
				facit = str(location) + ' ' + str(category) + ' Administrator'
				activity = 'Created New Line'
				
				logchange_parameters = {'assetID': lineID, 'changeDescription':activity, 'modifiedBy':controller, 'modifierRole':facit}
				
				system.db.runNamedQuery('Assets/Lines/LogChangeLine', logchange_parameters)
				
				self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
				self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
	
	except Exception as e:
		system.perspective.print("Error: {}".format(str(e)))

```

---

<div class="post-metadata">

**Author:** ![chaerrydairy](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chaerrydairy](https://forum.inductiveautomation.com/u/chaerrydairy)\
**Post date:** [August 7, 2025, 5:30pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/5 "2025-08-07T17:30:28Z")

</div>

I am also having another error of the same kind on line 37 on the if statement as well

---

<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:** [August 7, 2025, 5:30pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/6 "2025-08-07T17:30:55Z")

</div>

> [@chaerrydairy](#):
>
> `system.perspective.print("Now create asset)`

No closing quote.

The forum software event highlights it correctly 😃

---

<div class="post-metadata">

**Author:** ![chaerrydairy](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chaerrydairy](https://forum.inductiveautomation.com/u/chaerrydairy)\
**Post date:** [August 7, 2025, 5:32pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/7 "2025-08-07T17:32:15Z")

</div>

Wow, that was annoying…

However another error has shown up on the line just below on line 38

```python
if IDAllowed:
	    	parameters = {
	            'assetID': assetID,
	            'assetName': assetName,
	            'lineID': lineID,
	            'roleID': 1 if role_name == 'Primary' else 2,
	            'modifiedBy': modified,
	            'andonDisplay': andonDisplay
	        }

```

---

<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:** [August 7, 2025, 5:32pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/8 "2025-08-07T17:32:26Z")

</div>

You also have a mix of tabs and spaces for indentation, which is a bad idea:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4ebf4b70f3f6e23260862dee229b1c34467e7717.png)

Fixed:

```python
assetID = self.parent.parent.getChild("AssetIDDetails").getChild("IDDisplay").props.text	
assetName = self.parent.parent.getChild("AssetNameDetails").getChild("NameDisplay").props.text
lineID = self.parent.parent.getChild("LineIDDetails").getChild("IDDisplay").props.text
lineName = self.parent.parent.getChild("LineNameDetails").getChild("NameDropdown").props.value
locationID = self.parent.parent.getChild("LocationDetails").getChild("LocationDropdown").props.value
categoryID = self.parent.parent.getChild("CategoryDetails").getChild("CategoryDropdown").props.value
role_name= self.parent.parent.getChild("RoleAndWorkcenterContainer").getChild("RoleDropdown").props.value
andonDisplay = self.parent.parent.getChild("AndonDisplayDetails").getChild("AndonDisplay").props.text
roleID = 0
if role_name == 'Primary':
	roleID = 1
else:
	roleID = 2
modified = self.session.custom.clockNumber

try:
	IDAllowed = False

	if assetID == '':
		# Auto-generate Asset ID
		maxIDDataset = system.db.runNamedQuery('Assets/GetMaxID')
		if maxIDDataset.rowCount > 0:
			assetID = int(maxIDDataset[0]['Asset_ID']) + 1
		IDAllowed = True
	else:
		# Check if custom Asset ID already exists
		check = system.db.runNamedQuery('Assets/CheckExist', {'assetID': assetID})
		if check.rowCount > 0:
			raise Exception("ID already exists, try another ID")
		else:
			IDAllowed = True
	
	system.perspective.print("Now create asset")
	
	# --- Create asset if ID is allowed ---
	if IDAllowed:
		parameters = {
			'assetID': assetID,
			'assetName': assetName,
			'lineID': lineID,
			'roleID': 1 if role_name == 'Primary' else 2,
			'modifiedBy': modified,
			'andonDisplay': andonDisplay
		}

		result = system.db.runNamedQuery('Assets/CreateAsset', parameters)

		if result:
			# log change in Change_Log DB table
			# retrieve group ID given selected group name in dropdown menu
			# categoryID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column2").getChild("Category").getChild("CategoryDropdown").props.value	
			categories = {1: 'Molding', 2: 'Paint', 3: 'Assembly', 4: 'Warehouse'}
			category = categories[categoryID]
			
			# Location from dropdown 
			#locationID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column1").getChild("Location").getChild("LocationDropdown").props.value	
			location = locationID
			
			controller = int(self.session.custom.clockNumber)
			facit = str(location) + ' ' + str(category) + ' Administrator'
			activity = 'Created New Line'
			
			logchange_parameters = {'assetID': lineID, 'changeDescription':activity, 'modifiedBy':controller, 'modifierRole':facit}
			
			system.db.runNamedQuery('Assets/Lines/LogChangeLine', logchange_parameters)
			
			self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
			self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')

except Exception as e:
	system.perspective.print("Error: {}".format(str(e)))

```

---

<div class="post-metadata">

**Author:** ![chaerrydairy](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chaerrydairy](https://forum.inductiveautomation.com/u/chaerrydairy)\
**Post date:** [August 7, 2025, 5:33pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/9 "2025-08-07T17:33:07Z")

</div>

I believe that the error is coming somewhere from there, I will go through and redo the formatting

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 7, 2025, 5:40pm UTC](https://forum.inductiveautomation.com/t/script-format-error/109493/10 "2025-08-07T17:40:49Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5a2522eaeefdcfbe2d018b6d55073fba6c234707.png)

Right-click in the editor and turn on Whitespace. It will show the difference between tabs and spaces.
