I have a script which creates a project record and...
# ask-stanley-ai
a
I have a script which creates a project record and attaches it to the sales order. I now need to assign a resource to the project. How do I do that using SuiteScript 2.1?
c
AI generated answer (using internal Slack threads):
To assign a resource to a project using SuiteScript 2.1, you would need to load the project record, then access the 'resourceallocation' sublist and add a new line to it. Here's a simplified example of how you might do this:
Copy code
javascript
var projectRecord = record.load({
    type: record.Type.PROJECT_TASK,
    id: 'your_project_id'
});

var resourceSublistId = 'resourceallocation';

projectRecord.selectNewLine({
    sublistId: resourceSublistId
});

projectRecord.setCurrentSublistValue({
    sublistId: resourceSublistId,
    fieldId: 'resource',
    value: 'your_resource_id'
});

projectRecord.commitLine({
    sublistId: resourceSublistId
});

projectRecord.save();
In this example, replace 'your_project_id' with the internal ID of the project you want to assign the resource to, and 'your_resource_id' with the internal ID of the resource you want to assign. Please note that this is a simplified example and you may need to set additional fields on the resource allocation sublist line depending on your specific requirements. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823730588
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818420529
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815918
Please provide your feedback on this answer.
a
How can I update the 'Billable' field at the line of an already created expense report using celigo?