Skip to main content
Best answer

How to set the exchange rate for an invoice using a custom action

  • September 29, 2025
  • 3 replies
  • 22 views

Forum|alt.badge.img

I have tried using a custom action. The update invoice as currency, but no exchange rate.

Could you post the correct code or point me in the right direction using a custom event to do this.

Thanks,

Best answer by john mccauley

Thank you for your response.

I did manage to do this. QuickBooks has an exchange rate field. Needed to calculate the home amount correctly. I custom field would not work.

The issue was using the QuickBooks api correctly.

After battling with copilot that kept saying it could not be done. I fed it a link to the api. After that it did write the required code for a custom action.

// Define and export an async function to update an invoice in QuickBooks Online

export async function updateInvoiceWithExchangeRate({

  invoiceId,

  syncToken,

  exchangeRate,

  currencyCode,

  currencyName,

  customerId,

  companyId

}: {

  invoiceId: string;

  syncToken: string;

  exchangeRate: number;

  currencyCode: string;

  currencyName: string;

  customerId: string;

  companyId: string;

}): Promise<{ result: string }> {

  // Construct the URL using the companyId

  const url = `https://quickbooks.api.intuit.com/v3/company/${companyId}/invoice`;

 

  // Prepare the request body with the necessary invoice details

  const body = {

    Id: invoiceId,

    SyncToken: syncToken,

    CurrencyRef: {

      value: currencyCode,

      name: currencyName // Include the currency name in the request body

    },

    ExchangeRate: exchangeRate,

    CustomerRef: {

      value: customerId

    },

    sparse: true

  };

 

  // Make a POST request to the QuickBooks API using fetchWithZapier

  const response = await fetchWithZapier(url, {

    method: 'POST',

    headers: {

      'Content-Type': 'application/json',

      'Accept': 'application/json'

    },

    body: JSON.stringify(body)

  });

 

  //return { Reponse: JSON.stringify(response) };

 

  // Use throwErrorIfNotOk to handle any errors in the response

  await response.throwErrorIfNotOk();

 

  // Return a success message if the request was successful

  return { result: 'Invoice updated successfully' };

}

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

  • Zapier Staff
  • October 8, 2025

Hi John, Welcome to the Community! 👋

I see that QuickBooks does not support displaying the default Exchange Rate field in invoices, according to this response by a QuickBooks representative here.

However, further down in the thread, another representative explains that it is possible to set up a custom field to display this value. To confirm, have you set up a custom field to pass the exchange rate? 

If not, you can follow the steps suggested there and then map that custom field in the Create Invoice step within your Zap.

I hope this helps, and don't hesitate to reach out if you have any other questions!


Forum|alt.badge.img
  • Author
  • Beginner
  • Answer
  • October 9, 2025

Thank you for your response.

I did manage to do this. QuickBooks has an exchange rate field. Needed to calculate the home amount correctly. I custom field would not work.

The issue was using the QuickBooks api correctly.

After battling with copilot that kept saying it could not be done. I fed it a link to the api. After that it did write the required code for a custom action.

// Define and export an async function to update an invoice in QuickBooks Online

export async function updateInvoiceWithExchangeRate({

  invoiceId,

  syncToken,

  exchangeRate,

  currencyCode,

  currencyName,

  customerId,

  companyId

}: {

  invoiceId: string;

  syncToken: string;

  exchangeRate: number;

  currencyCode: string;

  currencyName: string;

  customerId: string;

  companyId: string;

}): Promise<{ result: string }> {

  // Construct the URL using the companyId

  const url = `https://quickbooks.api.intuit.com/v3/company/${companyId}/invoice`;

 

  // Prepare the request body with the necessary invoice details

  const body = {

    Id: invoiceId,

    SyncToken: syncToken,

    CurrencyRef: {

      value: currencyCode,

      name: currencyName // Include the currency name in the request body

    },

    ExchangeRate: exchangeRate,

    CustomerRef: {

      value: customerId

    },

    sparse: true

  };

 

  // Make a POST request to the QuickBooks API using fetchWithZapier

  const response = await fetchWithZapier(url, {

    method: 'POST',

    headers: {

      'Content-Type': 'application/json',

      'Accept': 'application/json'

    },

    body: JSON.stringify(body)

  });

 

  //return { Reponse: JSON.stringify(response) };

 

  // Use throwErrorIfNotOk to handle any errors in the response

  await response.throwErrorIfNotOk();

 

  // Return a success message if the request was successful

  return { result: 'Invoice updated successfully' };

}


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • October 10, 2025

Great work here ​@john mccauley 👏 Thanks for sharing this! I’m so glad you were able to get this solved and really appreciate you including the code you used for that custom action. This will be super helpful for others who are also looking to set exchange rates so I’ll mark it as the best answer. Thanks again! 🧡