Skip to main content

Hi there,

I’d like to confirm if there is a way in CLM (perhaps using the expression builder) to convert currency numbers in words, as such “USD 200.000,00 (two hundred thousand dollars)”.

This would be great considering our daily contracts frequently use this drafting style.

Hello @samuelportes 

I have one code that support the DocuSign c# library. In which you can convert the  number into the word.

 

stringi] units =
    { "Zero", "One", "Two", "Three","Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
    "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen","Seventeen", "Eighteen", "Nineteen" };

string ] tens =
    { "", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };

string ConvertAmountToString(string amountString)
{
    try
    {
        char ] charsToTrim = { ' ' };

        double amount = double.Parse(System.Text.RegularExpressions.Regex.Replace(amountString, "n$,]", "").Trim(charsToTrim));
        long amount_int = (long)amount;
        long amount_dec = (long)Math.Round((amount - (double)(amount_int)) * 100);

        if (amount_dec == 0)
        {
            return ConvertString(amount_int) + " Dollars";
        }
        else
        {
            return ConvertString(amount_int) + " Dollars and " + ConvertString(amount_dec) + " Cents";
        }
    }
    catch (Exception e)
    {
        // TODO: handle exception 
    }
    return "";
}


string ConvertString(long i)
{
    if (i < 20)
    {
        return units i];
    }
    if (i < 100)
    {
        return tens;i / 10] + ((i % 10 > 0) ? " " + ConvertString(i % 10) : "");
    }
    if (i < 1000)
    {
        return units i / 100] + " Hundred"
                + ((i % 100 > 0) ? " And " + ConvertString(i % 100) : "");
    }
    if (i < 100000)
    {
        return ConvertString(i / 1000) + " Thousand"
        + ((i % 1000 > 0) ? " " + ConvertString(i % 1000) : "");
    }



    if (i < 1000000)
    {
        return ConvertString(i / 100000) + " Hundred"
        + ((i % 100000 > 0) ? " " + ConvertString(i % 100000) : "");
    }



    if (i < 1000000000)
    {
        return ConvertString(i / 1000000) + " Million"
                + ((i % 1000000 > 0) ? " " + ConvertString(i % 1000000) : "");
    }
    return ConvertString(i / 1000000000) + " Billion"
            + ((i % 1000000000 > 0) ? " " + ConvertString(i % 1000000000) : "");
}

return ConvertAmountToString(GetVariableValue("NumberToWordsConversion"));


 

 I hope this helps!


Hi Pawan,

Thank you very much. It helped a lot!

I’m struggling to find a way to merge the variable generated by this code into a document generated through CLM.

Do you know how can I make this?

Best,

Samuel


Hey samuel,

So for merging this information into the document can be done by 2 ways.

1. Through the workflow you can merge this variable into the document. “No Limitation”

2. You can use the word’s functionality to change the number into the word, but here is the limitation of this that you can only convert the number into word or letter till 6 digits. if it goes 7 digit or beyond 7 then it will not work.

Thanks!


Thank you, Pawan. Do you know which workflow step could be used in order to follow the option one? In my case, the workflow starts with a form that already genereates a document. Do I have to use the XML Merge step?

 

Best,


Thank you, Pawan. Do you know which workflow step could be used in order to follow the option one? In my case, the workflow starts with a form that already genereates a document. Do I have to use the XML Merge step?

 

Best,

No you are gonna use the “Merge Tracked Content’ and for this step to work you need to write “Track Name” merge tag. and it is gonna be quite complex to build as well as explaining here that how you are gonna configure but I will try my best.


Pawan, thank you very much for your availability and support.

I’ve included the “track name” merge tag in my template, and also included a “merge tracked content” step in my workflow. However, the “merge tracked content” step presents the error “The document does not contain tracked content with Unique Name: Valor_extenso”.

 

Do you have any suggestions to solve this?

 


Hello @samuelportes 

Make unique name = “ValorExtenso_1”

and merge tag will be = <# <Content Select="//Teste_valor" Optional="true" TrackName=”ValorExtenso”/> #>

this will work


Excelent, Pawan!

It worked now.

Thank you very much!


Reply