inserting data one table to another custom table using scheduler tasks

vikas Kumar asked on June 17, 2020 06:38

Hi Everyone,

I want to add data one table to another custom table by the help of scheduler. whenever I will run the scheduler it should bring the data one table to another custom table. for this scenario what is required, please.

Recent Answers


Juraj Ondrus answered on June 17, 2020 07:33

Well, you will need to create a custom scheduled task and then use the custom tables API to work with the data in the code.

1 votesVote for this answer Mark as a Correct answer

vikas Kumar answered on June 17, 2020 11:12 (last edited on June 17, 2020 11:21)

Hi @Juraj,

can you verify my code?

using CMS.CustomTables; using CMS.DataEngine; using CMS.EventLog; using CMS.Scheduler; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Custom { public class CustomTask : ITask { /// /// Info object representing the scheduled task public string Execute(TaskInfo ti) { string details = "Custom scheduled task executed. Task data: " + ti.TaskData;

        // Logs the execution of the task in the event log
        EventLogProvider.LogInformation("CustomTask", "Execute", details);

        // Returns a null value to indicate that the task executed successfully
        // Return an error message string with details in cases where the execution fails
        return null;




    }

}

}

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 17, 2020 11:59

Not sure what to inspect in the code as it looks like just a sample to log an entry to Event log when the task is executed. Copied from the documentation.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.