Edits history of script submission #19854 for ' Update a unit of measure (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a unit of measure
     * Updates an existing custom unit of measure by setting field values. Any fields not provided remain unchanged. Units of measure already in use cannot be modified.
    
    
    Permissions and other requirements
    
    SubscriptionInventory Control, Order Entry, or Purchasing
    ConfigurationInventory Control, Order Entry, or Purchasing must be enabled for custom units of measure to add, edit, or delete units of measure.
    User typeBusiness
    PermissionsList, View, Edit Units of Measure
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		abbreviation?: string
    		numberOfDecimalPlaces?: number
    		isBase?: false | true
    		parent?: { key?: string; id?: string; href?: string }
    		conversionFactor?: number
    		href?: string
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & { id?: {} }
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/inventory-control/unit-of-measure/${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