1
votes

I'm trying to create a Business Account from Leads (ScreenID: CR301000) via Acumatica (Version: 17.200.0401) REST API in Postman with the action (Create Business Account) in Acumatica, called ConvertLeadToBAccount in the endpoint with the parameters: AccountClass, AccountName, BAccountID.

I tried the following:

{
    "entity": {
        "LeadID": {
            "value": "100005"
        }
    },
        "parameters": {
        "AccountClass": {
            "value": "BUSINESS"
        },
        "AccountName": {
            "value": "MACRO"
        },
        "BAccountID": {
            "value": "GIMON1"
        }
    }
}

However, it's not converting the lead into a business account.

This is the Post Request: Post Request in Postman

The LeadID is previously obtained via this Get Request: Get Request via Postman

Unlike other actions we have executed, this one uses parameters, but we cannot find examples with the use of parameters.

1
What version of Acumatica are you using? - samol518
Version: 17.200.0401 - Luis Rojas

1 Answers

0
votes

This was a know issue that was reported to the engineering team of Acumatica and a fix was release in these versions:

  • for the 2017 R2 version: 17.202.0016

  • for the 6.1 version: 6.10.1417

If upgrading to one of the aforementioned builds is not an option, please consider creating the following customization for the LeadMaintExt BLC to override the standard ConvertToBAccount action:

using PX.Data;
using System.Collections;
using System.Linq;

namespace PX.Objects.CR
{
    public class LeadMaintExt : PXGraphExtension< LeadMaintExt >
    {
        public PXAction<Contact> convertToBAccount;
        [PXUIField(DisplayName = Messages.ConvertToBAccount, 
             MapEnableRights = PXCacheRights.Update, 
             MapViewRights = PXCacheRights.Select)]
        [PXButton(ImageKey = PX.Web.UI.Sprite.Main.Process)]
        public virtual IEnumerable ConvertToBAccount(PXAdapter adapter)
        {
            if (Base.IsContractBasedAPI)
            {
                Base.AccountInfo.View.SetAnswer(null, WebDialogResult.Cancel);
                var contacts = Base.convertToBAccount.Press(adapter)
                    .RowCast<Contact>().ToList();

                foreach (Contact l in contacts)
                {
                    Base.Save.Press();
                    Contact lead = l;
                    lead.ConvertedBy = Base.Accessinfo.UserID;
                    PXLongOperation.StartOperation(Base, () =>
                    {
                        try
                        {
                            LeadMaint.ConvertToAccount(lead, 
                                Base.AccountInfo.Current);
                        }
                        catch (PXRedirectRequiredException ex)
                        {
                            var accountMaint = ex.Graph;
                            accountMaint.Actions.PressSave();
                        }
                    });
                }
                return contacts;
            }
            else
            {
                return Base.convertToBAccount.Press(adapter);
            }
        }
    }
}