0

Create a project change order

by
Published Oct 17, 2025

Creates a new project change order. You must specify a unique ID when creating a project change order unless document sequencing is configured, in which case the ID is auto-generated.

Script sage_intacct Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type SageIntacct = {
3
	token: string
4
}
5
/**
6
 * Create a project change order
7
 * Creates a new project change order. You must specify a unique ID when creating a project change order unless document sequencing is configured, in which case the ID is auto-generated.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	body: {
12
		key?: string
13
		id?: string
14
		href?: string
15
		project?: { key?: string; id?: string; name?: string; href?: string }
16
		location?: { key?: string; id?: number; name?: string; href?: string }
17
		projectChangeOrderDate?: string
18
		state?: 'draft' | 'posted'
19
		changeRequestStatus?: { key?: string; id?: string; href?: string }
20
		description?: string
21
		projectContract?: {
22
			key?: string
23
			id?: string
24
			name?: string
25
			href?: string
26
		}
27
		projectContractLine?: {
28
			key?: string
29
			id?: string
30
			name?: string
31
			href?: string
32
		}
33
		priceEffectiveDate?: string
34
		totalCost?: string
35
		totalPrice?: string
36
		sendToContact?: { key?: string; id?: string; href?: string }
37
		item?: { key?: string; id?: string; name?: string; href?: string }
38
		customer?: { key?: string; id?: string; name?: string; href?: string }
39
		scope?: string
40
		inclusions?: string
41
		exclusions?: string
42
		terms?: string
43
		schedule?: {
44
			scheduledStartDate?: string
45
			actualStartDate?: string
46
			scheduledCompletionDate?: string
47
			revisedCompletionDate?: string
48
			substantialCompletionDate?: string
49
			actualCompletionDate?: string
50
			noticeToProceedDate?: string
51
			responseDueDate?: string
52
			executedOnDate?: string
53
			scheduleImpact?: string
54
		}
55
		internalReference?: {
56
			referenceNumber?: string
57
			initiatedBy?: { key?: string; id?: string; name?: string; href?: string }
58
			verbalApprovalBy?: {
59
				key?: string
60
				id?: string
61
				name?: string
62
				href?: string
63
			}
64
			issuedBy?: { key?: string; id?: string; name?: string; href?: string }
65
			issuedOnDate?: string
66
			approvedBy?: { key?: string; id?: string; name?: string; href?: string }
67
			approvedOnDate?: string
68
			signedBy?: { key?: string; id?: string; name?: string; href?: string }
69
			signedOnDate?: string
70
			source?: string
71
			sourceReferenceNumber?: string
72
		}
73
		externalReference?: {
74
			referenceNumber?: string
75
			verbalApprovalBy?: { key?: string; id?: string; href?: string }
76
			approvedBy?: { key?: string; id?: string; href?: string }
77
			approvedOnDate?: string
78
			signedBy?: { key?: string; id?: string; href?: string }
79
			signedOnDate?: string
80
		}
81
		attachment?: { key?: string; id?: string; href?: string }
82
		status?: 'active' | 'inactive'
83
		audit?: {
84
			createdDateTime?: string
85
			modifiedDateTime?: string
86
			createdBy?: string
87
			modifiedBy?: string
88
		}
89
		entity?: { key?: string; id?: string; name?: string; href?: string }
90
	} & {}
91
) {
92
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/project-change-order`)
93

94
	const response = await fetch(url, {
95
		method: 'POST',
96
		headers: {
97
			'Content-Type': 'application/json',
98
			Authorization: 'Bearer ' + auth.token
99
		},
100
		body: JSON.stringify(body)
101
	})
102
	if (!response.ok) {
103
		const text = await response.text()
104
		throw new Error(`${response.status} ${text}`)
105
	}
106
	return await response.json()
107
}
108