Edits history of script submission #19821 for ' Update a renewal template (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a renewal template
     * Updates an existing order entry renewal template by setting field values. Any fields not provided remain unchanged.
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		name?: string
    		href?: string
    		description?: string
    		salesTxnCreation?: {
    			enableTxnCreation?: false | true
    			transactionDefinition?: { key?: string; id?: string; href?: string }
    			daysBeforeAfter?: number
    			beforeOrAfterContractEnd?: 'before' | 'after'
    			txnDateOnRenewedDocument?: 'calculatedDate' | 'contractEndDatePlusOneDay'
    			txnLineItemStartDate?: 'sameAsDocumentDate' | 'withInheritedOffsetFromParent'
    		}
    		contractPricing?: {
    			pricingType?: 'sameAsOriginal' | 'defaultPricing' | 'markupOrMarkdown'
    			markup?: 'percentageMarkup' | 'percentageDiscount' | 'actualMarkup' | 'actualDiscount'
    			markupValue?: string
    		}
    		renewalNotifications?: {
    			customerEmail?: {
    				enableNotification?: false | true
    				from?: string
    				to?: 'customerContact' | 'customerBillToContact' | 'customerShipToContact'
    				daysBeforeAfter?: number
    				beforeOrAfterContractRenewal?: 'before' | 'after'
    				emailTemplate?: { key?: string; id?: string; href?: string }
    			}
    			internalEmail?: {
    				enableNotification?: false | true
    				from?: string
    				to?: string
    				beforeOrAfterContractRenewal?: 'before' | 'after'
    				daysBeforeAfter?: number
    				emailTemplate?: { key?: string; id?: string; href?: string }
    			}
    		}
    		salesforceOpportunity?: {
    			enableSalesforceOpportunity?: false | true
    			beforeOrAfterContractRenewal?: 'before' | 'after'
    			daysBeforeAfter?: string
    			renewalName?: string
    			inheritProductsFromParent?: false | true
    			stage?:
    				| 'prospecting'
    				| 'qualification'
    				| 'needsAnalysis'
    				| 'valueProposition'
    				| 'idDecisionMakers'
    				| 'proposalPriceQuote'
    				| 'negotiationReview'
    				| 'closedWon'
    				| 'closedLost'
    		}
    		latestVersion?: string
    		transactionType?: 'salesTransaction' | 'contract' | 'evergreen'
    		renewalState?: 'inProgress' | 'draft'
    		defaultTerm?: { period?: 'years' | 'months' | 'days'; length?: string }
    		status?: 'active' | 'inactive'
    		entity?: { key?: string; id?: string; name?: string; href?: string }
    	} & { id?: {} }
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/order-entry/renewal-template/${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