display error message when a sequence is skipped based on some validations

Hi all,

I have a form with select checkbox, I want to display error message if a sales order is skipped it should happen only based on part number, revision and Project type = maintenance combination.

like based on part number and revision I need to collect and if that sequence is skipped i need to show error message, if it contains different revision it can allow to skip

Do you mean that you run a query with certain conditions and you want to know which records you have in database that don’t meet the criteria?

Obviously you can’t get this information from your current query - it fetches just what meets conditions and it has no information about the rest. What you can do is running an extra query for the orders you’re interested, or you could fetch both “fitting” and “missing” and distinguigh between them in AX.

This is the code i did in clicked method, here i want to add a condition if part number and revision is different they can skip

 select count(RecId) from spcheck where spcheck.check == noyes::Yes && spcheck.ProjectType == SalesOrderProjectType::Maintenance ;
        countrec =spcheck.RecId;
        //info(strfmt("%1",countrec));
        breakpoint;
        if(countrec == 1)
        {
                select firstonly shiptemp order by shiptemp.SalesID asc where shiptemp.partnumber == spl.PartNumber && shiptemp.ProjectType == SalesOrderProjectType::Maintenance
                && shiptemp.projectionId == spl.ProjectionId && shiptemp.CurrentUser == curUserId() ;
                if(shiptemp.check == noyes::No)
            {
                 error("Cannot ship new order when Old Orders exists");
                // salesprojectionshippingbreakuptemp_ds.reread();
                 salesprojectionshippingbreakuptemp_ds.research(false);
                 return;
            }
        }
        else if(countrec > 1)
        {
            while select shiptemp1 order by shiptemp1.SalesID asc where shiptemp1.partnumber == spl.PartNumber && shiptemp1.ProjectType == SalesOrderProjectType::Maintenance
           && shiptemp1.projectionId == spl.ProjectionId && shiptemp1.CurrentUser == curUserId()
            {
                i += 1;
                if(shiptemp1.check == noyes::No && i <= countrec)
                {
                    error("Cannot ship new order when Old Orders exists");
                   // salesprojectionshippingbreakuptemp_ds.reread();
                    salesprojectionshippingbreakuptemp_ds.research(false);
                    return;
                }
                else if(shiptemp1.check == noyes::No && i > countrec)
                {
                    break;
                }
            }

        }

here part num , revision and type is same so if that highlighted record isn’t selected error should show, if it is different revision they can skip that and even if it is selected it shouldn’t show error

First of all, let me format your code so we (and you) can read it more easily:

select count(RecId) from spcheck 
	where spcheck.check == NoYes::Yes
	   && spcheck.ProjectType == SalesOrderProjectType::Maintenance;
	   
countRec = spcheck.RecId;

if (countRec == 1)
{
	select firstonly shiptemp
		order by shiptemp.SalesID asc
		where shiptemp.PartNumber == spl.PartNumber
		   && shiptemp.ProjectType == SalesOrderProjectType::Maintenance
		   && shiptemp.projectionId == spl.ProjectionId
		   && shiptemp.CurrentUser == curUserId();
		   
	if (shiptemp.Check == NoYes::No)
	{
		 error("Cannot ship new order when Old Orders exists");
		 salesprojectionshippingbreakuptemp_ds.research(false);
		 return;
	}
}
else if(countRec > 1)
{
	while select shiptemp1
		order by shiptemp1.SalesID asc
		where shiptemp1.PartNumber == spl.PartNumber
		   && shiptemp1.ProjectType == SalesOrderProjectType::Maintenance
           && shiptemp1.projectionId == spl.ProjectionId
		   && shiptemp1.CurrentUser == curUserId()
	{
		i++;
		if (shiptemp1.Check == NoYes::No && i <= countRec)
		{
			error("Cannot ship new order when Old Orders exists");
			salesprojectionshippingbreakuptemp_ds.research(false);
			return;
		}
		else if(shiptemp1.Check == NoYes::No && i > countRec)
		{
			break;
		}
	}
}

Unfortunately your requuirement (“if part number and revision is different they can skip”) is still not clear to me. When you say “different”, different than what? And what do you mean by “they can skip”?

Please don’t try to to save time by not explaining properly what you want. It’s the most importantant part and we can’t help you don’t give us enough details.