Edits history of script submission #19836 for ' Update a task (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a task
     * Updates an existing task by setting field values. Any fields not provided remain unchanged.
    
    
    Permissions and other requirements
    
    SubscriptionProjects
    User typeBusiness, Project Manager
    PermissionsEdit Tasks
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		name?: string
    		description?: string
    		parent?: { key?: string; id?: string; name?: string; href?: string }
    		project?: {
    			key?: string
    			id?: string
    			name?: string
    			startDate?: string
    			endDate?: string
    			href?: string
    		}
    		customer?: { key?: string; id?: string; name?: string; href?: string }
    		item?: { key?: string; id?: string; name?: string; href?: string }
    		planned?: { startDate?: string; endDate?: string }
    		actual?: { startDate?: string; endDate?: string }
    		duration?: {
    			planned?: number
    			plannedBillable?: number
    			estimated?: number
    			estimatedBillable?: number
    			actual?: number
    			actualBillable?: number
    			approved?: number
    			approvedBillable?: number
    			remaining?: number
    		}
    		percentComplete?: number
    		observedPercentComplete?: number
    		isMilestone?: false | true
    		isUtilized?: false | true
    		isBillable?: false | true
    		wbsCode?: string
    		priority?: number
    		taskStatus?: 'notStarted' | 'planned' | 'inProgress' | 'completed' | 'onHold'
    		timeType?: { key?: string; id?: string; href?: string }
    		class?: { key?: string; id?: string; name?: string; href?: string }
    		attachment?: { key?: string; id?: string; href?: string }
    		dependentOn?: { key?: string; id?: string; name?: string; href?: string }
    		productionUnits?: { estimate?: number; description?: string }
    		root?: { id?: string; key?: string; name?: string; href?: string }
    		standardTask?: { id?: string; key?: string; name?: string; href?: string }
    		href?: string
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & { id?: {}; project?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/projects/task/${key}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago