Batch parallelism/multithreading in Dynamics 365 FO
Tuesday, December 19, 2023
Monday, December 18, 2023
Friday, December 15, 2023
How to pass Arguments/records in RDP Report through form or how to open report from the Form using controller class X++ in Dynamics 365 FO
Pass arguments in RDP Report through form in D365 FO on Dynamicscommunity101
Selection changed and active method in Dynamics 365 FO
1. Selection Changed Method:
- This method is triggered when the selection of a record in a grid or a form changes.
- It is commonly used to handle scenarios where actions need to be taken based on the user's selection of a record. For example, enabling or disabling buttons, displaying additional details of the selected record in another form part, or refreshing data based on the new selection.
- The Selection Changed method is associated with the form's data source and is typically overridden in the form's data source class.
2. Active Method:
- The Active method is called whenever a record in a form is activated or when the focus is set on a record.
- It's used to perform actions every time a record becomes active, which might not necessarily be due to a change in selection. For example, it can be used to display additional details of the record or to execute some logic related to the active record.
- This method is also associated with the form's data source and can be overridden to provide custom logic whenever a record becomes active in the form.
In essence, while the "Selection Changed" method is specifically about the change in the selection of records, the "Active" method is more about a record gaining focus or becoming the currently active record, regardless of whether it was selected previously or not. Both are important in managing the behavior and interaction of forms in Dynamics 365 F&O.
Dynamics 365 FO code to generate access token and parse the JSON response using contract class to get the access token
1. Class LSGenerateToken :
using System.Net.Http;
using System.Text;
internal final class LSGenerateToken
{
public static void main(Args _args)
{
str responseJson;
HttpClient httpClient = new HttpClient();
str requestUrl = 'https://login.microsoftonline.com/TENANTID/oauth2/token';
str body = strFmt("grant_type=client_credentials&client_id=%1&client_secret=%2",
'XXXXXXXXXXXXXXXXX','YYYYYYYYYYYYYYYYYYYYY');
// Send the request and get the response
HttpResponseMessage response = httpClient.PostAsync(requestUrl, new StringContent(body, Encoding::UTF8, "application/x-www-form-urlencoded")).Result;
str responseBodyStr;
if (response.IsSuccessStatusCode)
{
// Parse the response body
var responseBody = response.Content.ReadAsStringAsync().Result;
responseBodyStr = responseBody;
}
else
{
// Handle error
throw error(strFmt("Failed to get access token. Status code: %1", response.StatusCode));
}
LSAccessTokenContract _Contract = FormJsonSerializer::deserializeObject(classNum(LSAccessTokenContract), responseBodyStr);
info(strfmt("Access token = %1",_Contract.parmaccess_token()));
}
}
2. LSAccessTokenContract :
[DataContract]
class LSAccessTokenContract
{
str token_type;
str expires_in;
str ext_expires_in;
str expires_on;
str not_before;
str resource;
str access_token;
[DataMember("token_type")]
public str parmtoken_type(str _token_type = token_type)
{
token_type = _token_type;
return token_type;
}
[DataMember("expires_in")]
public str parmexpires_in(str _expires_in = expires_in)
{
expires_in = _expires_in;
return expires_in;
}
[DataMember("ext_expires_in")]
public str parmext_expires_in(str _ext_expires_in = ext_expires_in)
{
ext_expires_in = _ext_expires_in;
return ext_expires_in;
}
[DataMember("expires_on")]
public str parmexpires_on(str _expires_on = expires_on)
{
expires_on = _expires_on;
return expires_on;
}
[DataMember("not_before")]
public str parmnot_before(str _not_before = not_before)
{
not_before = _not_before;
return not_before;
}
[DataMember("resource")]
public str parmresource(str _resource = resource)
{
resource = _resource;
return resource;
}
[DataMember("access_token")]
public str parmaccess_token(str _access_token = access_token)
{
access_token = _access_token;
return access_token;
}
}
Thursday, December 14, 2023
Mastering Transaction Control in Dynamics 365 FO Understanding ttsBegin ttsCommit and ttsAbort
Thursday, December 7, 2023
Relationship type property while creating relation in Dynamics 365 FO
In Dynamics 365 Finance and Operations (F&O), the following are the types of relationships between entities:
Association: An association is a relationship between two or more entities where they are linked together based on some common attribute or characteristic. For example, When a customer places an order, there is an association between the customer entity and the order entity, linked by a unique customer ID.
Composition: Composition is a type of association where the entities are dependent on each other, and the child entity cannot exist without the parent entity. For example, A customer profile may be composed of multiple sub-entities like billing addresses, shipping addresses, and payment methods. These sub-entities cannot exist without the customer profile.
Link: A link is a type of association that defines a connection between two entities but does not imply any dependency or ownership. For example, The customer entity could be linked to a loyalty program entity, indicating that this customer is a part of a specific loyalty program but not dependent on it.
Specialization: Specialization is a relationship between entities where one entity is a more specific version of another entity. For example, Customers can be specialized into different types such as "retail customer," "wholesale customer," or "online customer."
Aggregation: Aggregation is a relationship between entities where one entity is composed of or made up of other entities. For example, A household may aggregate multiple individual customer accounts under one umbrella, like a family account.
If you've made it this far, please leave a kind word. Your encouragement fuels my desire to produce and share even more valuable content.