Runnable classes: Implementing Finds and Inserts

To call a Runnable class from URL,

https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=[ClassName]

We want to be able to pass parameters to this class thru the URL, something like this,

https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=[ClassName]&id=001

To achieve this, we use the URLUtility system class found in the ApplicationFoundation package.


URLUtility urlUtility = new URLUtility();

Str courseId = urlUtility.getQueryParamValue('id');

INF_DMS_Courses FoundCourse;
FoundCourse = INF_DMS_Courses::find(courseId);

Info(strFmt("Course ID: %1, Name: %2, Term: %3", FoundCourse.CourseId, FoundCourse.Name, FoundCourse.Term));


Same goes for insertions,

URLUtility urlUtility = new URLUtility();
Str courseId = urlUtility.getQueryParamValue('id');
Str courseName = urlUtility.getQueryParamValue('name');
Str courseTerm = urlUtility.getQueryParamValue('term');

INF_DMS_Courses courseTable;
INF_DMS_CoursesEnumTerm courseTermEnum;
courseTable.CourseId = courseId;
courseTable.Name = courseName;
courseTable.Term = str2Enum(courseTermEnum, courseTerm);
//courseTable.Term = queryValue(INF_DMS_CoursesEnumTerm::courseTerm);
courseTable.doInsert();


Info(strFmt("%1 inserted.", coursed));



Comments

Popular posts from this blog

Can't see the Workflow button on the form menu?