Updating a Job Variable via C# - VisualCron - Forum

Community forum

I'd like to 'insert' a variable into an email from an external application, so I created a job variable {JOB(Active|Variable|specialmessage)}

I'd like to update it programmatically before running the job, tried this:
using (Client c = new Client())
using (Server s = c.Connect(conn, true))
var job = s.Jobs.GetJobByName(jobName);
s.Jobs.JobVariables.AddUpdate("{JOB(Active|ID)}", "specialmessage", "let's see if this works");
JobRunResultClass jrsc = s.Jobs.Run(job.Id, false, false, false, string.Empty, false, string.Empty, null, false);

but that doesn't seem to do the trick. Am I missing something?
nevermind, i found an old post that helped:
var job = s.Jobs.GetJobByName(jobName);
JobVariableClass jvc = new JobVariableClass()
Key = "specialmessage",
ValueObject = c.Encrypt("myValue")

JobRunResultClass jrsc = s.Jobs.Run(job.Id, false, true, false, string.Empty, false, string.Empty, new List<JobVariableClass>() { jvc }, true);
Scroll to Top