Custom Imports—Credit Value

Just wanted to say thanks for custom imports. I’ve been terrified of updating sections of my install because I didn’t want to use the GUI and click a thousand times. Once you get familiar with yaml (and troubleshoot a lot and get help from Sandra here and there) it’s remarkable. Moreover, doing custom fields isn’t as daunting as I once thought!

An example script that might help even one person. I’ve added credit value as a custom course field, and I also needed to go through and update departments and course blurbs, so I’ve combined it all into one import.

details:
 type: coursesCustomData
 name: CustomData
 desc: Updates department, credit value, and blurb for each course
 category: Course
 table: gibbonCourse
 modes: { update: true, insert: false}
access:
 module: Timetable Admin
 action: Manage Courses & Classes
primaryKey:
 gibbonCourseID
uniqueKeys:
 - [ gibbonSchoolYearID, gibbonCourseID ]
table:
 gibbonSchoolYearID:
  name: "School Year"
  desc: "School year name, as set in School Admin. Must already exist."
  args: { filter: schoolyear, required: true, readonly: true, custom: true }
  relationship: { table: gibbonSchoolYear, key: gibbonSchoolYearID, field: name }
 gibbonCourseID:
  name: "Course"
  desc: "Short Name"
  args: { filter: string, required: true }
  relationship: { table: gibbonCourse, key: gibbonCourseID, field: [ nameShort, gibbonSchoolYearID ]}
 gibbonDepartmentID:
  name: "Learning Area"
  desc: "Short Name"
  args: { filter: string, custom: true }
  relationship: { table: gibbonDepartment, key: gibbonDepartmentID, field: nameShort }
 description:
  name: "Blurb"
  desc: ""
  args: { filter: html }
 credits:
  name: "Credits"
  desc: "Credit value of the course"
  args: { filter: /^[1-9]$/, readonly: true, serialize: fields }
 fields:
  name: "Custom Fields"
  desc: "Custom fields JSON data"
  args: { filter: customfield, serialize: fields, custom: true }
1 Like

Hi @cSanders

You mentioned your post might help even one person — it definitely helped me.

I’ve tried your script, and it’s behaving exactly as I’d expect for updating data, especially the custom field. I also really like the use of regex for input validation.

I had asked @sandra for example YAML import files (particularly beyond the Custom Fields – User Context example), and this fills in a big gap.

Thanks for sharing your work, it’s very much appreciated.

Link for reference: