Updating a Job Variable via C# - VisualCron - Forum

Community forum

david.fisher
2017-03-24T15:30:14Z
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())
{
try
{
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?
david.fisher
2017-03-24T15:42:54Z
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