Hi,
I'm having some trouble with a project script that I'm writing. The script is as follows;
//Add task to the order
item.grid[0].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);
//Add task to the order
item.grid[1].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);
If I run either of these lines in isolation then the script runs fine. The task is added to the relevant item. However, when I try to run the script as shown then both tasks are added to the first SPAWNED_ORDER item only. I have attached a screenshot.
Thanks in advance for your help,
David.
David,
Can you please attach the full script (with libraries if it uses any), I need to see what all of everything is going on in it.
OK. I think I added you to the tenant (I found your email address)
The action script you're looking for is '_TSM_OAIssued'
Thanks,
David
David,
This could be one of two things, so let’s check the easier one first.
If you were to condense the spawn location to a variable and then try to operate the script do you still get the same results?
Ie:
var spawnA=item.grid[0].SPAWNED_ORDER.project;
var spawnB=item.grid[1].SPAWNED_ORDER.project;
spawnA.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);
spawnB.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);
Also food for thought:
What is your plan for when you have more than two task to add and can you always insure the locations of the items are going to be where you say they are going to be?
The theory behind what you are trying to do is good, but I think you might find some issues with it down the road.
Hi Joe,
I tried your modified script. Same problem remains. Perhaps I could use loadItem() to force the second project item to load??
Regarding my strategy for multiple tasks on projects - I have a plan. The main problem is that you cannot create relationships between items in the same script that spawns the itemm- but you can create links. So behind each project I have another workspace that links project numbers to tasks via the grid. So each column in the grid (apart from the first one that contains the project id) has a link to a different type of spawned task. So in one script I can spawn the project and tasks - then in the next I can link them all together. Rows in the grid will have different combinations of tasks depending on the type of project they are.
David.
OK,
using loadItem doesn't solve it either. I'm probably not using it correctly (actually I'm not eve sure what loadItem is for) but it was worth a shot.
//Add task to the order
item.grid[0].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);
//Add task to the order
var test = loadItem(item.grid[1].SPAWNED_ORDER.descriptor.dmsID);
test.project.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);
Hi Joe,
Based on our conversation today I tested a modified script that does not utilise any linking via grids. Guess what? Same problem occurs. It looks like a problem with the project scripting. What do you think?
var task1 = loadItem(12186)
var order1 = loadItem(12187);
order1.project.addTask(task1);
var task2 = loadItem(12188)
var order2 = loadItem(12185);
order2.project.addTask(task2);
Joe,
I simplified the script even further to remove the linked tasks from the scope. The same issue still persists. Both tasks are created on the first project.
var order1 = loadItem(12187);
order1.project.addTask('Test1');
var order2 = loadItem(12185);
order2.project.addTask('Test2');
David,
Trung and I did some testing and this does fall into the limitation of the scripting engine. The limitation is that we can only write to multiple records if we are writing to the details tab only. If you need to write to a different tab then that is currently limited to a one to one relationship.
OK. Thanks guys.
Is this a limitation that can be corrected easily or should I look at alternative scripting/design solutions?
David.
David,
At this point I would look for an alternative method of development.
Guys,
Just FYI. Further testing has revealed that this limitation applies to reading as well as writing from the project tab.
David.