Administer > Smart Analytics Administration > Tailoring > Implement OCR in a field other than the Description field

Implement OCR in a field other than the Description field

User Role: Administrator

Optical Character Recognition (OCR) is an out-of-box feature for Smart Ticket, which can extract texts from images, and then put the text into the interaction records when you submit requests by using Smart Ticket.

In an out-of-box Service Manager system, the Smart Ticket OCR feature saves and displays the extracted image content in the Description field. The subsequent Smart Interaction suggestions are also based on the Description field. However, if you want to use a field other than the Description field for the Smart Interaction OCR feature, you can follow the instructions in this section to tailor your system.

To use a field other than the Description field for the Smart Interaction OCR feature, follow these steps:

  1. Add your new field to the “incidents” table:

    1. From the System Navigator, click Tailoring > Database Dictionary.

    2. Search for and open the “incidents” table.

    3. Add a new field in the table. For example, you can use “description.ocr” as the name of the new field.

      Note To ensure the new field can store the strings extracted from images, we recommend that when you add the new field, select the array data type first, and then select the character data type.

    4. Save the table.
  2. Add new Smart Ticket configuration tasks for your new field:

    1. From the System Navigator, click System Administration > Ongoing Maintenance > Smart Analytics > Smart Ticket.

    2. Delete the out-of-box “Standard category field” and “Service category field” configuration tasks.

    3. Add a new “Category” configuration, and then add “Description Ocr” to the Content Fields list on the Configurations tab.

    4. Add a new “Affected Service” configuration, and then add “Description Ocr” to the Content Fields list on the Configurations tab.

  3. Add the new “description.ocr” field to the OCR related Java scripts. To do this, follow the steps that are appropriate for your environment:

    Service Manager Codeless

    1. From the System Navigator, click Tailoring > Process Designer > Rule Sets.

    2. Search for and clone the “sd.idol.ocr” rule set.

      Note The out-of-box rule sets and workflows are HPE Proprietary, you need to clone the related rule sets and workflows, and then make changes as necessary so that your tailoring can take effect.

    3. From the cloned the rule set, open the OCR rule, and then add the description.ocr parameter as appropriate to the “lib.IDOL_SMIS.addOCRTask” JS call. These are shown in bold in the following scripts.

      if (vars.$G_src && (system.vars.$lo_idol_img_enabled || system.vars.$lo_idol_enabled)) {
      	if (vars['$G.multi']) {
          	company = vars['$lo.operator']['company'];
          	lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', company, 'description.ocr');
          } else {
          	lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', '', 'description.ocr');
          }
      } else {
      	var attachments = record.getAttachments();
      	var attLen = 0;
      	for (var i = 0; i < attachments.length; i++) {
      		if (lib.IDOL_Utilities.isImage(attachments[i])){
      			attLen++;
      			break;
      		}
      	}
      	//call OCR interface
      	if (vars.$G_ess && (system.vars.$lo_idol_img_enabled || system.vars.$lo_idol_enabled) && attLen > 0)
      	{
          	if (vars['$G.multi']) {
          		company = vars['$lo.operator']['company'];
          		lib.IDOL_SMIS.addOCRTask(record, 'OCR', company, 'description.ocr');
          	} else {
          		lib.IDOL_SMIS.addOCRTask(record, 'OCR', '', 'description.ocr');
          	}
      	} else if ((vars.$G_ess && (system.vars.$lo_idol_img_enabled || system.vars.$lo_idol_enabled) && attLen === 0)) {
      		if (vars['$G.multi']) {
          		company = vars['$lo.operator']['company'];
          		lib.IDOL_SMIS.addOCRTask(record, 'AutoFill', company, 'description.ocr');
          	} else {
          		lib.IDOL_SMIS.addOCRTask(record, 'AutoFill', '', 'description.ocr');
          	}
      	}
      }
    4. Search for and clone the “sd.idol.ocr.action” rule set. Then, from the cloned rule set, in the Process OCR rule, add the “description.ocr” parameter to the “lib.IDOL_Utilities.processOCRFG” JS call as shown in bold in the following scripts.

      lib.IDOL_Utilities.processOCRFG(record, 'description.ocr')
    5. Make other changes as necessary so that the updated rule sets can take effect. For example, clone the related workflow, and then insert the updated rules sets to the cloned workflow.

    Service Manager Classic or Hybrid

    1. From the System Navigator, click Tailoring > Document Engine > Processes.

    2. Search for and open the “cc.first.log” process.

    3. Go to the Final Javascript tab.
    4. Add the description.ocr parameter to the “lib.IDOL_SMIS.addOCRTask” JS call. These are shown in bold in the following scripts.

      if (vars['$L.action'] == 'logcatalog'){
        return;
      }
      if (vars.$lo_idol_img_enabled || vars.$lo_idol_enabled) {
        //if is src, add to smis task
        if (vars.$G_src) {
          if (vars['$G.multi']) {
              company = vars['$lo.operator']['company'];
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', company, 'description.ocr');
            } else {
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', '', 'description.ocr');
            }
            return;
        }
      
        var attachments = vars['$L.file'].getAttachments();
        var attLen = 0;
        for (var i = 0; i < attachments.length; i++) {
          if (lib.IDOL_Utilities.isImage(attachments[i])){
            attLen++;
            break;
          }
        }
      
        //call OCR interface
        if (vars.$G_ess && attLen > 0) {
            if (vars['$G.multi']) {
              company = vars['$lo.operator']['company'];
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', company, 'description.ocr');
            } else {
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'OCR', '', 'description.ocr');
            }
        } else if (vars.$G_ess && attLen === 0) {
          if (vars['$G.multi']) {
              company = vars['$lo.operator']['company'];
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'AutoFill', company, 'description.ocr');
            } else {
              lib.IDOL_SMIS.addOCRTask(vars['$L.file'], 'AutoFill', '', 'description.ocr');
            }
        }
      }

  4. Re-train the two new Smart Ticket configurations that you added in step 2.

  5. When the training is finished, try the OCR related feature. The Smart Ticket OCR feature now saves and displays the extracted image content in the new Description Ocr field.