Accessing the data for Production Environment is one of the major challenges which consultants face especially when there is a data discrepancy issue and because of this issue major financial statements are getting impacted.
Microsoft has given us very limited privileges when it comes to Sandbox environments and that too can be done only in UAT Environments. For Production all the control is there with Microsoft Product Team only. So the Programmers have somehow found a way to run basic SQL scripts in Production Environment and perform some data manipulations.
class SQLHelper{public static Container getExpectedResultFromQuery(str queryStmt){int i;int colType;container expectedSubResult, expectedResult;int counter;ResultSet resultSet;;try{// Executes the Query statement on the back end database.resultSet = SQLHelper::resultSetExecuteQuery(queryStmt);while(resultSet.next()){expectedSubResult = connull();for ( i = 1; i <= resultSet.getMetaData().getColumnCount(); i++){colType = resultSet.getMetaData().getColumnType(i);switch (colType){case 0: // Stringcase 8: // MemoexpectedSubResult += resultSet.getString(i);break;case 1: // IntergerexpectedSubResult += resultSet.getInt(i);break;case 2: // RealexpectedSubResult += resultSet.getReal(i);break;case 3: // DateexpectedSubResult += resultSet.getDate(i);break;case 4: // EnumexpectedSubResult += resultSet.getBoolean(i);break;case 6: // UtcDateTimeexpectedSubResult += dateTime2str(resultSet.getDateTime(i));break;case 45: // GuidexpectedSubResult += guid2str(resultSet.getGuid(i));break;case 49: // Int64expectedSubResult += resultSet.getInt64(i);break;default:break;}// End of Switch}// End of forexpectedResult += [expectedSubResult];}info(con2Str(expectedSubResult));// End of while}catch{Error('error');}return expectedResult;}
private server static ResultSet resultSetExecuteQuery(str strQuery){Connection connection = new Connection();Statement statement = connection.createStatement();SqlStatementExecutePermission permission;ResultSet resultSet;// Get the formatted Query statement.strQuery = strfmt(strQuery,SRSStatementQuery::getDbSchemaPrefix());permission = new SqlStatementExecutePermission(strQuery);permission.assert();resultSet = statement.executeQuery(strQuery);return resultSet;}
7) Now Create SQLBrowser class which will call the functionality of SQLHelper
class SqlBrowser
{
public static void Main(Args _args)
{
Dialog dialog= new Dialog("SQL");
DialogField queryInput = Dialog.addField(extendedTypeStr(MyExtendedDataType),"SQL query");
dialog.run();
if(dialog.closedOk() && queryInput.value())
{
str query = queryInput.value();
container con = SQLHelper::getExpectedResultFromQuery(query);
info(con2Str(con));
File::SendStringAsFileToUser(con2Str(con),'sqlresult.txt');
//exporting result of select statement to txt file
}
}
Hi - nice article.
ReplyDeleteDoes there exist any kind of guide or documentation to accessing common Dynamics elements - for example querying a list of Products, Contacts, Quotes or Orders?
Thanks,
Neal
Hi ,
ReplyDeleteThere are different tables for different masters in D365 FO.
FOr e,g For Products - The main table is inventtable
For Contacts - The maintable is ContactPerson
For Sales Quotation - The main table is SalesQuotationTable (Header) , SalesQuotationLines (Lines)
For Sales Order - The Main table is SalesTable (Header) , SalesLine (Lines)
Do let me know what exactly you are looking for.
You can find support or guidance from individuals who know your technology precisely and possibly have experienced this issue previously and figured out how to investigate it. IT consulting services Brampton
ReplyDeletea SQL infusion assault can happen. By sending unforeseen information, an assailant can produce and submit SQL questions to a web applications data set. https://onohosting.com/
ReplyDelete