Issue with Creating Task in Multiple Projects - Works in One Place, Not Another

So, I’m sure that I’ve done something simple and stupid, but I’ve been staring at this for two days and I need another pair of eyes:

I have several modal forms that generate a list of tasks based on entries provided. The form for an event works perfectly, generating tasks and sections in both the “show” project and the various department work lists. The main task generation call is this:

Create Task in Section Function
let tdata = processTask(taskname, proj.tag, proj.bcf);
//Returns a makecopy(template[taskname]) with project base custom fields applied
if(tdata.projects == null){//PM Task. Only needs to exist in the project specific task
tdata.projects = proj.gid;
}else{//Needs to be in a department project as well
tdata.projects += “,” + proj.gid;
}
return await createTask(tdata, user) etc

Again there is no problem generating the above (I just tried it again to confirm.) There’s another function that deals with creating a quote request for the custom shop. These tasks are a little more complicated so they don’t go through the createTaskInSection function, but a createCustomQuoteTask function:

let holder = makecopy(template.customquote);

**Setting Custom Fields and Notes like processTask does but specific to the quote request**
holder.projects += "," + proj.gid;

return await createTask(holder, user) etc

Here I’m getting the error:
Couldn’t create task: “projects: Not a Long: CustomDepartmentGID,ProjectGID

I’ve tried editing the function to only do one or the other and it works fine. I have no idea why createTaskInSection is getting through fine, while createCustomQuoteTask is throwing an error.

@Kariah_Petrille - are you passing an array of the project IDs or just a string separating them by commas?

I’ve tried using arrays, and it always spits back an error, so I’ve been passing comma-separated lists in both functions.

@Kariah_Petrille - what is the error when you pass an array? I think (not 100% sure) the error from your OP is because it’s reading the GID,GID as a single string and rejecting it (the not a Long error).

EDIT: not sure why you’d be getting different results if your two functions are essentially the same, though.

I haven’t tried it in so long, I just tried it again and it didn’t create an error. Last year when I first made the app, it was giving me the same error “Not a Long”

The problem I do have is that now it’s only wanting to take custom fields from the base project, not the ones specific to the custom shop. I can try cutting the custom fields out of the task and then pushing them in an updateTask request after it’s created.

I still don’t understand why the comma-split list works in one function and not the other.

Actually it appears to still be doing the same thing with the custom shop fields when I do it after task creation… just got this error:

Couldn’t update task"Custom field with ID Anticipated Item Due Date GID is not on given object"

But when I do a getTask requesting custom fields it shows on the list

@Kariah_Petrille - what type of fields are you working with? If they are enums, are you passing the value GID? (I assume you are, if this wasn’t an issue previously, but just checking)

The field that threw the error was a date field:

holder.custom_fields[Anticipated Item Due Date GID] = {date: value.customdate}

the one enum field that’s specific to the custom department is being passed like so:

holder.custom_fields[Quote with Custom Crates GID] = value.customcrates;

The drop-down value in question has values set to the GIDs of the relevant enum options

Stupid mistake found: I forgot to put the workspace in the Custom Quote tasks. I’m not sure why that made the projects spit back “Not a Long” but it works fine now.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.