Item Demand Plan Add lines via SuiteScript

I have been unable to figure out how to create item demand plans and not have the default start/end date be current year.  I am using SuiteScript 2.x and when I update the start date the line 0 reference is not updating.

     var currentYear = new Date()
            var startDate   = new Date(demandDate.getFullYear(), 0, 1);
            var endDate     = new Date(demandDate.getFullYear(), 11, 31);
            loadDemandPlan.setValue(‘startdate’, formatNSDate(startDate));
            loadDemandPlan.setValue(‘enddate’, formatNSDate(endDate));
            //months = (demandDate.getFullYear() – currentYear.getFullYear()) * 12
            months = demandDate.getMonth();
           // months = months – 1;
            log.debug(“months ” + months);
            log.debug(“year ” + loadDemandPlan.getValue(‘year’));
            log.debug(“startdate ” + loadDemandPlan.getValue(‘startdate’));
            log.debug(“enddate ” + loadDemandPlan.getValue(‘enddate’));
            var lineId = months;
            loadDemandPlan.selectLine({ sublistId: ‘demandplandetail’, line: lineId });
            loadDemandPlan.setCurrentSublistValue({ sublistId: ‘demandplandetail’, fieldId: ‘quantity_1_’, value: quantity })


Example plan date is 4/1/2024

but even if I set the start date to 1/1/2024

the line 0 always records to the 1/1/2023 and line 1-11 are the same 2023 dates

No matter what I do the quantity always get record to the 2023 year, never will I get the date to go into 2024.

 

Has anyone ever worked with this and figured out how to use a UserEventScript to import data into the Item Deman Plan.

 

The user event is a on a custom table where users are loading a demand into a project for specific items that have long lead time purchases and we need to be able to source the requirements back to a project.

 

 

Rookie Asked on October 23, 2023 in SuiteScript.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor