Skip to main content
Question

Create setVariable prototype interaction via API


Brian1

I am trying to set up a Set Variable prototype connection with the API but when I copy the data structure for an actual “SET_VARIABLE” prototype reaction I get this error.

This is the connection I am setting up:

	let getVariableReaction = (newChar, varId) => {

		let newReaction = {
			type: "SET_VARIABLE",
			variableId: varId,
			variableValue: {
				resolvedType: "STRING",
				type: "EXPRESSION",
				value: {
					resolvedType: "STRING", // <-- this fixed my issue
					type: "EXPRESSION",
					value: {
						expressionArguments: [
							{
								resolvedType: "STRING",
								type: "VARIABLE_ALIAS",
								value: {
									id: varId,
									type: "VARIABLE_ALIAS"
								}
							},
							{
								resolvedType: "STRING",
								type: "STRING",
								value: newChar
							}
						],
						expressionFunction: "ADDITION"
					}
				}
			}
		}

		return newReaction;
	}

Am I missing something?? I copied it directly from what I see in Figma when I set the same interaction up in the UI.

This is what I’m copying from Figma when I look at a set variable interaction done in the UI.


SOLVED. Human error!

Needed to add resolvedType: 'STRING' in variableValue.value

This topic has been closed for comments

2 replies

Brian1
  • Author
  • 3 replies
  • August 31, 2023

SOLVED.

Just needed to add resolvedType: 'STRING' to `variableValue.value


James_Yang
Figmate
  • Figmate
  • 82 replies
  • September 14, 2023

Following up here, we just released official documentation and typings for advanced prototyping functionality in the plugin API: Version 1, Update 77 | Plugin API


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings