Maintenance plan records created on asset insert / asset modification are not associating with the asset correctlyDescriptionIf you have a maintenance plan that automatically adds new records to the plan then this association doesn't always work as expected. The sm_m2m_maint_plan_to_record responsible for linking the asset to the plan isn't populated with the correct values.Steps to Reproduce 1. Have facilities management and planned maintenance installed with demo data.2. Create a maintenance plan against alm_facility with condition asset_tag starts with TC (demo data has 2 records).3. Create a maintenance schedule for that plan.4. Click Associate plan with filtered records.5. Go to one of the alm_facility records and add the related list 'Maintenance Plan Record -> Asset'. Notice the new plan has been associated as expected with the alm_facility record.6. Create a new alm_facility record with an asset tag starting with TC. The plan does not show up because the sm_m2m_maint_plan_to_record is not created with the correct values.WorkaroundIn the Script Include - "global.PlannedMaintenanceUtils"in the function - "associateRecord"after the line - this._addAssetRecord(newPlanGr, docTable, sourceId);Add this snippet :var baseTable = new TableUtils(planGr.table).getAbsoluteBase();if (planGr.type == 'general') {if(baseTable == 'alm_asset')newPlanGr.setValue("asset", sourceId);if(planGr.table == 'sys_user')newPlanGr.setValue("user",sourceId);if(baseTable == 'cmdb_ci')newPlanGr.setValue("ci", sourceId);}if (planGr.type == 'model_based')newPlanGr.setValue("ci",sourceId);NOTE : This should only be added in the code block of the already present - "if (!newPlanGr.next()) " which looks like this:associateRecord: function(current, planId) {var planGr = new GlideRecord("sm_maint_plan");...........................if (!newPlanGr.next()) {..................this._addAssetRecord(newPlanGr, docTable, sourceId);/** Start of New lines from CSTASK127258 ****/var baseTable = new TableUtils(planGr.table).getAbsoluteBase();if (planGr.type == 'general') {if(baseTable == 'alm_asset')newPlanGr.setValue("asset", sourceId);if(planGr.table == 'sys_user')newPlanGr.setValue("user",sourceId);if(baseTable == 'cmdb_ci')newPlanGr.setValue("ci", sourceId);}if (planGr.type == 'model_based')newPlanGr.setValue("ci",sourceId);/** End of New lines from CSTASK127258 ****/}..........}Related Problem: PRB1446125