Validation to check if the document is attached to sales order if not picking list should be disabled

Hi all,

When creating sales order i need to check if the documents have been attached to sales order if not then picking list should be disabled… I have created three new types in document management form and when i select the document attach button these three types have to be attached to do picking list for the sales order… Plz help me out …

Hi Avinash,

Try and excecute the following steps to get the desired result,

Step 1:- Go to Docuref Table, create a new method called filestatus,

Public boolean filestatus(salesTable _salesTable)
{
boolean fileattached = false;
Docuref DocurefTableloc;
;

select DocurefTableloc where DocurefTableloc.RefCompanyId == _salesTable.dataAreaId
&& DocurefTableloc.RefRecId == _salesTable.RecId;

if(DocurefTableloc)
{
fileattached = true;
return fileattached;
}

return fileattached;

}

Step 2:-

NOw go to Classes → Salestable form → enableUpdateJournalButtons method

in declaration part – > boolean filestatus;

after declaration, paste this code,

filestatus = docuref.filestatus(salesTable) // to check whether File is attached or not.

Below that u ll find the ------ > if (_buttonUpdatePickingList) this statement,

Just override the statement with this code,

if (_buttonUpdatePickingList)
{

if(filestatus == true)
{
_buttonUpdatePickingList.enabled(enablePickingListButton);
}
if(filestatus == false)
{
_buttonUpdatePickingList.enabled(false);
}
}

Cheers!!! Work done :slight_smile: I have tested the code and it is working fine for me… Revert back if you have any queries

Please try to find solutions by debugging the codes, you ll able to achiecve the solutions,

Without debugging AX customizations ll be difficult for you…

Hi Yeshwanth,

Thanks for your reply, But i have one more query here. In document management i have created three new file types and for each sales order we make all these

3 documents have to be attached and its mandatory… Now what i have done is i have created a new boolean field in the DocuType form General Tab, which is the master form . So the user has to check this check box and whenever he has to attach the document. Now i have to keep track of all the document typeid which are checked… The 3 types which i have created is mandatory and apart from that they can attach other type of documents also. So when i click on the document button in sales order DocuView form gets open where you can attach the document. In this form the user has to attach all the 3 new types which has been created. so how to check whether those are attached r not… Can i use sets and do it … Help me …

Hi Avinash,

Kindly Go to Docuref Table, in the method called filestatus,

Paste this code and check, I hope this is as per your requirement,

Public boolean filestatus(salesTable _salesTable)
{
boolean fileattached = false;
boolean repeat;
Docuref DocurefTableloc;
DocuTypeId type1,type2,type3;
str _null;
Container con;
;
_null = “”;
con = conins(con,1,_null);
con = conins(con,2,_null);
con = conins(con,3,_null);

// Collecting and storing the Document Types in the Container
while select DocurefTableloc where DocurefTableloc.RefCompanyId == _salesTable.dataAreaId
&& DocurefTableloc.RefRecId == _salesTable.RecId

{
if(conpeek(con,1)== “”)
{
con = conins(con,1,DocurefTableloc.TypeId);
}
else if(conpeek(con,2)== “”)
{
con = conins(con,2,DocurefTableloc.TypeId);
}
else if(conpeek(con,3)== “”)
{
con = conins(con,3,DocurefTableloc.TypeId);
}
}

type1 = conpeek(con,1);

type2 = conpeek(con,2);

// Comparing the Values to check whether both Document types are of same type

if(type1 == type2)
{
return fileattached;
}

type3 = conpeek(con,3);

if((type2 == type3)||(type1 == type3))
{
return fileattached;
}

// Mandatory Document types to be attached

if((type1 || type2 || type3 == “File”)&&
(type1 || type2 || type3 == “Image”)&&
(type1 || type2 || type3 == “Inbox”))
{
fileattached = true;
return fileattached;
}

return fileattached;

}

Hi Yeswanth,

Thanks you very much for your post… It worked fine…