Edits history of script submission #19824 for ' Update a role (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a role
     * Updates an existing role by setting field values. Any fields not provided remain unchanged.
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		description?: string
    		roleType?: 'enterprise' | 'eConsole' | 'multiEntityDistributed' | 'multiEntityShared'
    		applyTo?: 'loginAndSlideIn' | 'loginOnly' | 'slideInOnly'
    		rolePermissionAssignments?: {
    			key?: string
    			id?: string
    			href?: string
    			role?: { key?: string; id?: string; href?: string }
    			permission?: {
    				key?: string
    				id?: string
    				module?:
    					| 'accountsPayable'
    					| 'accountsReceivable'
    					| 'administration'
    					| 'advancedAuditTrail'
    					| 'aiMachineLearning'
    					| 'avalaraTax'
    					| 'budgets'
    					| 'cashManagement'
    					| 'company'
    					| 'console'
    					| 'consolidation'
    					| 'construction'
    					| 'constructionPayroll'
    					| 'contracts'
    					| 'customizationServices'
    					| 'dataDeliveryService'
    					| 'dataImport'
    					| 'digitalBoardBook'
    					| 'digitalNetworkSync'
    					| 'dimensionSync'
    					| 'dynamicAllocations'
    					| 'externalServicesProvider'
    					| 'fixedAssets'
    					| 'generalLedger'
    					| 'globalTransactionSecurity'
    					| 'intacctCollaborate'
    					| 'intacctSalesforceIntegration'
    					| 'intacctSalesforceIntegrationV2'
    					| 'interactiveCustomReportWriter'
    					| 'interactiveVisualExplorer'
    					| 'inventoryApplications'
    					| 'inventoryControl'
    					| 'managementConsole'
    					| 'managementConsoleConsolidation'
    					| 'msTeamsIntegration'
    					| 'multiEntity'
    					| 'myAccounting'
    					| 'myClients'
    					| 'myPractice'
    					| 'orderEntry'
    					| 'outboundPaymentServices'
    					| 'outsourcedPaymentServices'
    					| 'paymentServices'
    					| 'projects'
    					| 'purchasing'
    					| 'quickbooksMigration'
    					| 'realEstate'
    					| 'revenueManagement'
    					| 'saasMetrics'
    					| 'sageCloudServices'
    					| 'sageIntacctBudgetingAndPlanningConnector'
    					| 'sagePeople'
    					| 'siCollaboration'
    					| 'siFundRaising'
    					| 'smartTransaction'
    					| 'spendManagement'
    					| 'suppliesInventory'
    					| 'taxExport'
    					| 'taxes'
    					| 'timeAndExpenses'
    					| 'vendorCompliance'
    					| 'webServices'
    					| 'wellsFargoPaymentManager'
    					| 'loanManagement'
    					| 'budgetVsActual'
    					| 'depositoryManagement'
    				name?:
    					| 'budgets'
    					| 'contracts'
    					| 'dataDeliveryService'
    					| 'generalLedger'
    					| 'projects'
    					| 'taxes'
    					| '1099Reports'
    					| 'aatrix'
    					| 'accessLog'
    					| 'accountAllocationDefinitions'
    					| 'accountAllocationGroups'
    					| 'accountGroups'
    					| 'accountMappingStatus'
    					| 'accountTitleByEntity'
    					| 'accountingEntriesFile'
    					| 'accountingPeriods'
    					| 'accounts'
    					| 'accumulationTypes'
    					| 'achBankConfigurations'
    					| 'achFileGenerator'
    					| 'achPaymentFile'
    					| 'addToCheckRun'
    					| 'adjustAccount'
    					| 'adjustedAvailableCash'
    					| 'adjustmentJournals'
    					| 'adjustingJournalEntries'
    					| 'adjustments'
    					| 'affiliateEntityGroups'
    					| 'aisle'
    					| 'analysisAndReporting'
    					| 'apAccountLabels'
    					| 'apAdvances'
    					| 'apBillsApprovalLevels'
    					| 'apLedger'
    					| 'apOpenItemsRevaluationReport'
    					| 'apReleaseRetainage'
    					| 'apTerms'
    					| 'applicationAdministration'
    					| 'applicationSetup'
    					| 'applicationSubscriptions'
    					| 'applyPenalties'
    					| 'approveBills'
    					| 'approveExpenses'
    					| 'approveJournalEntries'
    					| 'approvePayments'
    					| 'approvePurchaseTransaction'
    					| 'approveReimbursements'
    					| 'approveTimesheets'
    					| 'approveVendors'
    					| 'arAccountLabelTaxGroups'
    					| 'arAccountLabels'
    					| 'arLedger'
    					| 'arOpenItemsRevaluationReport'
    					| 'arReleaseRetainage'
    					| 'arTerms'
    					| 'archive'
    					| 'assignmentCategories'
    					| 'assignmentConstraints'
    					| 'assignmentDependents'
    					| 'assignmentStatus'
    					| 'assignments'
    					| 'assuranceDocuments'
    					| 'attachmentFolders'
    					| 'attachments'
    					| 'auditLog'
    					| 'automatedTransactions'
    					| 'bankAccounts'
    					| 'bankCheckRegister'
    					| 'bankFeeds'
    					| 'bankFile'
    					| 'bankFileGenerator'
    					| 'bankInterestAndCharges'
    					| 'bankTransactionAssignmentRules'
    					| 'bankTransactionRuleSets'
    					| 'bankTransactionRules'
    					| 'bankTransactions'
    					| 'billBackTemplates'
    					| 'billingTemplate'
    					| 'bills'
    					| 'bin'
    					| 'binFace'
    					| 'binSize'
    					| 'books'
    					| 'buildAndDisassembleKits'
    					| 'bulkActionRuns'
    					| 'caDe542Report'
    					| 'calculationMethods'
    					| 'cancelService'
    					| 'cashAnalysis'
    					| 'cashBalances'
    					| 'changeRequestStatus'
    					| 'changeRequestTypes'
    					| 'changeRequests'
    					| 'chargeCardAccounts'
    					| 'chargeCardRegister'
    					| 'chargeCardTransactions'
    					| 'chargePayoffs'
    					| 'checkReconciliation'
    					| 'checkRegister'
    					| 'checkRun'
    					| 'checkRunDetail'
    					| 'checkingAccounts'
    					| 'checklistCategories'
    					| 'checklistItem'
    					| 'checklistOptions'
    					| 'checklistStatus'
    					| 'checklists'
    					| 'checks'
    					| 'class'
    					| 'classGroups'
    					| 'clearCompanyData'
    					| 'clients'
    					| 'cloudStorage'
    					| 'cmRevaluationReport'
    					| 'companyInformationMyPractice'
    					| 'companySetupChecklist'
    					| 'compensationTables'
    					| 'complianceRecords'
    					| 'complianceSetup'
    					| 'consolidateStructure'
    					| 'consolidateSubsidiaryData'
    					| 'constructionReporting'
    					| 'contactTaxGroup'
    					| 'contacts'
    					| 'contract'
    					| 'contractBillingTemplate'
    					| 'contractComplianceChecklist'
    					| 'contractComplianceTaskItem'
    					| 'contractExpenseTemplate'
    					| 'contractGroups'
    					| 'contractMEAPriceList'
    					| 'contractPriceList'
    					| 'contractRevenueTemplate'
    					| 'contractTypes'
    					| 'contributions'
    					| 'costCodeOverrides'
    					| 'costTypeGroups'
    					| 'costTypes'
    					| 'costingChanges'
    					| 'coverLetters'
    					| 'creditCardChargesAndOtherFees'
    					| 'customApplicationsWithUserDefinedDimensions'
    					| 'customReports'
    					| 'customerAgingReportsGraphs'
    					| 'customerBacklog'
    					| 'customerBankAccounts'
    					| 'customerCardAccounts'
    					| 'customerGLGroups'
    					| 'customerGroups'
    					| 'customerListReport'
    					| 'customerReconciliation'
    					| 'customerTypes'
    					| 'customers'
    					| 'cycleCounts'
    					| 'dashboard'
    					| 'datevDataExport'
    					| 'deferredRevenueDetails'
    					| 'deferredRevenueForecast'
    					| 'deferredRevenueForecastGraph'
    					| 'deferredRevenueRevaluationReport'
    					| 'departmentActivityReport'
    					| 'departmentGroups'
    					| 'departmentMappingStatus'
    					| 'departments'
    					| 'deposits'
    					| 'depositsRegister'
    					| 'documentNumbering'
    					| 'drillDownToAllTransactionsFromReports'
    					| 'dunningLevels'
    					| 'earningTypes'
    					| 'electronicReceipts'
    					| 'emailDeliveryLog'
    					| 'emailTemplates'
    					| 'employeeAgingReportsGraphs'
    					| 'employeeGroups'
    					| 'employeeOutOfOffice'
    					| 'employeePositions'
    					| 'employeeRates'
    					| 'employeeTypes'
    					| 'employees'
    					| 'entities'
    					| 'entity'
    					| 'estimateTypes'
    					| 'evergreenTemplates'
    					| 'exchangeRate'
    					| 'exchangeRateTypes'
    					| 'executiveSummary'
    					| 'expenseAdjustments'
    					| 'expenseApprovalLevels'
    					| 'expenseLedger'
    					| 'expensePaymentTypes'
    					| 'expenseSummaries'
    					| 'expenseTypes'
    					| 'exportClientTaxData'
    					| 'extendedGeneralLedger'
    					| 'externalAuthorizations'
    					| 'fairValuePriceListEntry'
    					| 'fairValuePriceLists'
    					| 'financialInstitution'
    					| 'financials'
    					| 'form1099'
    					| 'fulfillment'
    					| 'fundsTransfers'
    					| 'gaapAdjustingEntries'
    					| 'gaapAdjustmentJournals'
    					| 'ganttChart'
    					| 'generalLedgerRevaluationReport'
    					| 'generateAllocation'
    					| 'generateInvoices'
    					| 'generateLateCharges'
    					| 'generateReceipt'
    					| 'generateScheduledCharges'
    					| 'goBDDataExport'
    					| 'glAccountId'
    					| 'glMatching'
    					| 'glMatchingActivity'
    					| 'grantAdminRights'
    					| 'graphs'
    					| 'hourTypes'
    					| 'imports'
    					| 'initialOpenItems'
    					| 'interEntityAccountMapping'
    					| 'interactiveAccountGroups'
    					| 'interactiveCustomReports'
    					| 'interactiveDataVisualizationReports'
    					| 'interactiveReportAreas'
    					| 'interactiveReportsMasterConsumerRole'
    					| 'interEntityTransactions'
    					| 'inventoryAnalysis'
    					| 'inventoryControlSetup'
    					| 'inventoryCosting'
    					| 'inventoryCycles'
    					| 'inventoryFulfillment'
    					| 'inventoryJournal'
    					| 'inventoryRecurring'
    					| 'inventoryRegister'
    					| 'inventoryReorders'
    					| 'inventorySelfHelp'
    					| 'inventoryStatus'
    					| 'inventoryTotals'
    					| 'inventoryTransactionDefinitions'
    					| 'inventoryTransactions'
    					| 'inventoryValuation'
    					| 'invoicePolicies'
    					| 'invoices'
    					| 'itemActivity'
    					| 'itemGLGroups'
    					| 'itemGroups'
    					| 'itemProfitability'
    					| 'itemTaxGroups'
    					| 'items'
    					| 'jobs'
    					| 'journalActivityReport'
    					| 'journalEntries'
    					| 'journalEntryMappingLink'
    					| 'journals'
    					| 'kitAnalysis'
    					| 'laborClasses'
    					| 'laborShifts'
    					| 'laborUnions'
    					| 'landedCostAdjustment'
    					| 'landedCostsCategory'
    					| 'leases'
    					| 'linkSubsidiaries'
    					| 'loanTypes'
    					| 'loans'
    					| 'locationActivityReport'
    					| 'locationGroups'
    					| 'locationMappingStatus'
    					| 'locations'
    					| 'lotCategory'
    					| 'lotTracking'
    					| 'maintainInventoryValuation'
    					| 'manageBooks'
    					| 'manageContributions'
    					| 'managementFees'
    					| 'managePayments'
    					| 'managePlan'
    					| 'manageResourceSchedules'
    					| 'manageSchedules'
    					| 'manageSupplies'
    					| 'manageTimesheets'
    					| 'managersAndBrokers'
    					| 'manualPayment'
    					| 'meaAllocation'
    					| 'memorizedReportGroups'
    					| 'memorizedReports'
    					| 'messages'
    					| 'multiCurrencyProcessing'
    					| 'myExpenses'
    					| 'myTimesheets'
    					| 'notes'
    					| 'offlineJobQueue'
    					| 'opsbidBills'
    					| 'orderAnalysis'
    					| 'orderEntrySetup'
    					| 'orderEntryStatus'
    					| 'orderEntryTransactionDefinitions'
    					| 'orderEntryTransactions'
    					| 'otherReceipts'
    					| 'ownerDistribution'
    					| 'ownerInformation'
    					| 'ownershipStructure'
    					| 'partnerSyncEvents'
    					| 'payBills'
    					| 'payGroups'
    					| 'payInAdvance'
    					| 'paymentAccountInformation'
    					| 'paymentDefaults'
    					| 'paymentExchangeRateInformation'
    					| 'paymentManagerPayments'
    					| 'paymentRequests'
    					| 'payments'
    					| 'payrollReportCheck'
    					| 'payrollReportCheckSummary'
    					| 'payrollReportGrossPay'
    					| 'payrollReportPayModifier'
    					| 'payrollReportPtoActivity'
    					| 'payrollReportTax'
    					| 'payrollReportTaxSetup'
    					| 'payrollReportTimecard'
    					| 'payrollReportTimecardReport'
    					| 'pendingReimbursements'
    					| 'period'
    					| 'periodMappingStatus'
    					| 'physicalInventory'
    					| 'pickEngagements'
    					| 'pickList'
    					| 'pickingList'
    					| 'planStatement'
    					| 'poTransactionDefinitions'
    					| 'positionsAndSkills'
    					| 'postExpenseReports'
    					| 'postScheduledTransactions'
    					| 'postTemplates'
    					| 'postedAdvances'
    					| 'postedPayments'
    					| 'postedReimbursements'
    					| 'preparerSignoff'
    					| 'priceListEntry'
    					| 'priceLists'
    					| 'priceSchedules'
    					| 'printChecks'
    					| 'printEMailDocuments'
    					| 'printEMailDunningNotice'
    					| 'printEMailInvoices'
    					| 'printEMailStatements'
    					| 'printPaymentCopies'
    					| 'printedDocumentTemplates'
    					| 'priorPeriodCogsAdjustments'
    					| 'processContractSchedules'
    					| 'productLine'
    					| 'productLines'
    					| 'projectChangeOrders'
    					| 'projectContractRateTables'
    					| 'projectContractTypes'
    					| 'projectContracts'
    					| 'projectDetailReporting'
    					| 'projectEstimates'
    					| 'projectGroups'
    					| 'projectResources'
    					| 'projectStatus'
    					| 'projectTransactions'
    					| 'projectTypes'
    					| 'properties'
    					| 'ptoAccrualSchedules'
    					| 'ptoTypes'
    					| 'purchasePriceVarianceInvoicePriceVariance'
    					| 'purchasingAnalysis'
    					| 'purchasingApprovalLevels'
    					| 'purchasingRecurring'
    					| 'purchasingSetup'
    					| 'purchasingTransaction'
    					| 'purchasingTransactions'
    					| 'quickCheckEntry'
    					| 'quickDeposits'
    					| 'receiptHistory'
    					| 'receiptsRegister'
    					| 'receiveAdvances'
    					| 'reclassificationReport'
    					| 'reconcileBank'
    					| 'reconcileCreditCard'
    					| 'recoveryTemplates'
    					| 'recurringAllocations'
    					| 'recurringBills'
    					| 'recurringInvoices'
    					| 'recurringJournalEntries'
    					| 'recurringSchedules'
    					| 'recurringStatisticalJournalEntries'
    					| 'recurringTransactionForecast'
    					| 'recurringTransactionStatus'
    					| 'recurringTransactions'
    					| 'releaseToPay'
    					| 'renewalTemplates'
    					| 'renewalsForecast'
    					| 'replenishInventory'
    					| 'replenishmentFluctuatingForecasts'
    					| 'reporting'
    					| 'reportingAccounts'
    					| 'reportingAccountsMappingReport'
    					| 'reportingPeriods'
    					| 'requestSupplies'
    					| 'restrictionRelease'
    					| 'revenueRecognitionCategory'
    					| 'revenueRecognitionSchedule'
    					| 'revenueRecognitionTemplate'
    					| 'reverseConversions'
    					| 'reviewNote'
    					| 'reviewerSignoff'
    					| 'row'
    					| 'ruleSetPerformanceLog'
    					| 'runConsolidations'
    					| 'saasChangeType'
    					| 'saasSchedule'
    					| 'saasScheduleEntry'
    					| 'salesAnalysis'
    					| 'salesRecurring'
    					| 'salesTaxReport'
    					| 'salesforceSyncJobs'
    					| 'salesforceSynchronizationReport'
    					| 'salesforceSynchronizationStatus'
    					| 'sandbox'
    					| 'savingsAccounts'
    					| 'selectToReimburse'
    					| 'sendgridEmailDeliveryLog'
    					| 'serialMask'
    					| 'serialTracking'
    					| 'serviceAuthorizations'
    					| 'sharedLimits'
    					| 'shipmentHistory'
    					| 'shippingMethods'
    					| 'smartEventJobs'
    					| 'spendInsight'
    					| 'staffTimesheets'
    					| 'standardCostTypes'
    					| 'standardTasks'
    					| 'statisticalAccountId'
    					| 'statisticalAccountMappingStatus'
    					| 'statisticalAccounts'
    					| 'statisticalAdjustingJournals'
    					| 'statisticalAdjustingJournalEntries'
    					| 'statisticalJournalEntries'
    					| 'statisticalJournals'
    					| 'subledgerAndScmCombinedObjects'
    					| 'subledgerDocument'
    					| 'subscriptionUsage'
    					| 'subsidiaryAccounts'
    					| 'subsidiaryDepartments'
    					| 'subsidiaryLocations'
    					| 'subsidiaryReportingPeriods'
    					| 'subsidiaryStatisticalAccounts'
    					| 'summaries'
    					| 'switchToConsole'
    					| 'switchToManagementConsole'
    					| 'switchToMyAccounting'
    					| 'systemPayModifiers'
    					| 't5018ReportForCanada'
    					| 'taskGroups'
    					| 'taskResources'
    					| 'taskTypes'
    					| 'tasks'
    					| 'taxAdjustingEntries'
    					| 'taxAdjustmentJournals'
    					| 'taxAuthority'
    					| 'taxDetail'
    					| 'taxReciprocity'
    					| 'taxRecords'
    					| 'taxDetailBox'
    					| 'taxReport'
    					| 'taxSchedule'
    					| 'taxScheduleMap'
    					| 'taxSolutions'
    					| 'taxSubmissions'
    					| 'taxablePaymentsAnnualReport'
    					| 'taxesLink'
    					| 'templates'
    					| 'tenants'
    					| 'tenantConfiguration'
    					| 'territories'
    					| 'territoryGroups'
    					| 'timePreferences'
    					| 'timeSources'
    					| 'timeTypes'
    					| 'timeCards'
    					| 'timesheetRules'
    					| 'trades'
    					| 'transactionAllocations'
    					| 'transactionCurrencies'
    					| 'transactionRule'
    					| 'transactionTemplates'
    					| 'trialBalance'
    					| 'triggerLogs'
    					| 'unions'
    					| 'units'
    					| 'unitsOfMeasure'
    					| 'usageAndMetrics'
    					| 'userDefinedBooks'
    					| 'userDefinedJournalEntries'
    					| 'userDefinedJournals'
    					| 'users'
    					| 'vendorAgingReportsGraphs'
    					| 'vendorException'
    					| 'vendorGLGroups'
    					| 'vendorGroups'
    					| 'vendorInsuranceReport'
    					| 'vendorReconciliation'
    					| 'vendorTypes'
    					| 'vendors'
    					| 'viewAllocationLog'
    					| 'viewMyClients'
    					| 'viewMyServiceAuthorizations'
    					| 'warehouseGroups'
    					| 'warehouseTransfer'
    					| 'wipManagement'
    					| 'warehouses'
    					| 'zone'
    					| 'preferences'
    					| 'managementCompanies'
    					| 'billPercentageRent'
    					| 'salesEntry'
    					| 'leaseRenewal'
    					| 'expenseRecovery'
    					| 'reconcileCharges'
    					| 'reports'
    					| 'configuration'
    					| 'refunds'
    					| 'budgetVariance'
    					| 'revenueTxnEntries'
    					| 'payrollReportEmployee'
    					| 'payrollReportTrade'
    					| 'payrollReportPTOAccrualSchedule'
    					| 'glDynamicAccountReclassificationReport'
    				href?: string
    			}
    			accessRights?:
    				| 'ach'
    				| 'achSetup'
    				| 'add'
    				| 'addExpense'
    				| 'apiProxy'
    				| 'approvalLevel1'
    				| 'approvalLevel2'
    				| 'approvalLevel3'
    				| 'approvalLevel4'
    				| 'approvalLevel5'
    				| 'approvalLevel6'
    				| 'authorize'
    				| 'cancel'
    				| 'calendar'
    				| 'clone'
    				| 'close'
    				| 'config'
    				| 'confirm'
    				| 'delete'
    				| 'deleteExpense'
    				| 'edit'
    				| 'editExpense'
    				| 'enable'
    				| 'export'
    				| 'final'
    				| 'financial'
    				| 'group'
    				| 'ignore'
    				| 'import'
    				| 'impersonate'
    				| 'level1'
    				| 'level2'
    				| 'level3'
    				| 'level4'
    				| 'level5'
    				| 'level6'
    				| 'list'
    				| 'listExpenses'
    				| 'manualMatch'
    				| 'mapAccount'
    				| 'menu'
    				| 'modify'
    				| 'offsetAccount'
    				| 'open'
    				| 'overrideException'
    				| 'permission'
    				| 'post'
    				| 'print'
    				| 'readonly'
    				| 'readonlyExpense'
    				| 'receipts'
    				| 'reclass'
    				| 'reclassExpense'
    				| 'reconcile'
    				| 'refresh'
    				| 'release'
    				| 'reopen'
    				| 'report'
    				| 'resend'
    				| 'reversalEdit'
    				| 'reverse'
    				| 'reverseExpense'
    				| 'run'
    				| 'statutoryReportingPeriod'
    				| 'submit'
    				| 'subscribe'
    				| 'template'
    				| 'uncancel'
    				| 'unmask'
    				| 'upload'
    				| 'view'
    				| 'viewAll'
    				| 'void'[]
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    		}[]
    		roleUsers?: {
    			key?: string
    			id?: string
    			href?: string
    			role?: { key?: string; id?: string; href?: string }
    			user?: { key?: string; id?: string; href?: string }
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    		}[]
    		roleGroups?: {
    			key?: string
    			id?: string
    			href?: string
    			role?: { key?: string; id?: string; href?: string }
    			userGroup?: { key?: string; id?: string; href?: string }
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    		}[]
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & { id?: {} }
    ) {
    	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/role/${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