Auto Document Number based on Dropdown Input

Auto Document Number based on Dropdown Input

Hi Guys, 

I am a newbie and I am trying to automate document numbering based on user input from a dropdown or lookup input. For now, I used a long dropdown list and was following some youtube videos to create this code. 
The code seems to work, but it keeps running and doesn't stop.
It is a single form with two fields, the type of journey and the document code, based on the journey made, it will create a corresponding code. Now there can be many journey types and I was each to have a unique code that accumulates. 

Below is the code: 

LastJourney = Cargo_Manifest[Journey == input.Journey] sort by Added_Time DESC;
if(input.Journey == "BI-TIL")
{
input.Journey = "BI-TIL";
}
else if(input.Journey == "BI-NGY")
{
input.Journey = "BI-NGY";
}
else if(input.Journey == "BI-BCV")
{
input.Journey = "BI-BCV";
}
else if(input.Journey == "BI-VND")
{
input.Journey = "BI-VND";
}
else if(input.Journey == "BI-ELS")
{
input.Journey = "BI-ELS";
}
else
{
input.Journey = "BI-TCZ";
}
if(LastJourney.count(Manifest_Code) > 0)
{
getlstnmb = LastJourney.Manifest_Code.getsuffix("-");
getnumber = getlstnmb.getsuffix("-");
newNumber = getnumber.toNumber() + 1;
input.Manifest_Code = input.Journey + "-" + newNumber;
}
else
{
input.Manifest_Code = input.Journey + "-" + 1;
}

Thanks a lot for any help and sorry for any bother. 
thanks 
Richard
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方