We just put the pack id number, then just click on the printer icon to see the printer options and report style, then we just select the report style and finally we just make a click on the preview option to see the temporally pdf file after this we just save it to the local machine.
I think there should be a better way to get all these files (Like BPM) because do it one by one it’s going to take a few days.
Run one manually in kinetic with the dev menu open (F12)
Look at the calls it makes, copy the payloads. Thats the object you have to send to the api endpoint. There should only be a couple of fields that need changed for each packNum and they should be labeled easily enough to find. Then you can just loop through a list that you want and save the files to a local computer. Each task needs a unique taskNote so you can fetch it.
I threw a quick rough outline together.
import random
import time
class TaskStatus(Enum):
Active = "ACTIVE"
Pending = "PENDING"
Complete = "COMPLETE"
Error = "ERROR"
MultipleTasks = "MULTIPLE_TASKS"
FailedToFindTask = "FAILED_TO_FIND_TASK"
def calculateTaskNoteID():
now = datetime.now()
return str(now.year) + str(now.month) + str(now.day) + str(now.hour) + str(now.minute) + str(now.microsecond) + str(random.randint(0, 4294967295))
async def getTaskStatusFromTaskNote(taskNoteID):
resp = await ApiRequest_Get("IceBo.SysTaskSvc/GetList?whereClause=TaskNote%20%3D%20%27" + taskNoteID + "%27&pageSize=100&absolutePage=0"
)
try:
resp = resp["returnObj"]
if len(resp["SysTaskList"]) > 1:
return TaskStatus.MultipleTasks
return TaskStatus(resp["SysTaskList"][0]["TaskStatus"])
except:
return TaskStatus.FailedToFindTask
async def getReportBytesFromSysRowID(sysRowID):
return await ApiRequest_Post("IceBo.ReportMonitorSvc/GetReportBytes", {"sysRowId": sysRowID})
packReportObj = { #The Json object you got from the payload of the call
}
listOfPacks = [""]
async def main():
for pack in listOfPacks:
noteID = calculateTaskNoteID()
packReportObj ["ds"]["SomeReportNameParams"][0]["TaskNote"] = noteID
packReportObj ["ds"]["SomeReportNameParams"][0][PackNumField] = pack
await apiPostToEpicorAPI_RPT/ReportService/SubmitToAgent (packReportObj)
# Need to wait for task to finish
taskStatus = TaskStatus.Active
while taskStatus == TaskStatus.Active or taskStatus == TaskStatus.Pending:
time.sleep(5)
print("Checking task status")
taskStatus = await getTaskStatusFromTaskNote(noteID)
print(taskStatus, " - ", TaskStatus.Active.value)
if taskStatus == TaskStatus.Complete:
task = (await getReportFromTaskNote(noteID))["returnObj"]["SysRptLstList"][0]
pdfBytes = base64.b64decode((await getReportBytesFromSysRowID(task["SysRowID"]))["returnObj"])
with open('reportPythonTest.pdf', 'wb') as f:
f.write(pdfBytes)