Hello Andrew,
This is the code which I am using.
Thanks in advance.
public class ConcatenateSubnumber : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
ITracingService tracingService = context.GetExtension<ITracingService>();
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
if (workflowContext == null)
{
tracingService.Trace("Cheking the condition for workflow");
throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
}
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);
try
{
if (workflowContext.InputParameters.Contains("Target") && workflowContext.InputParameters["Target"] is Entity)
{
Entity objTarget = (Entity)workflowContext.InputParameters["Target"];
String fetchXmlString = @"<fetch distinct = 'false' mapping = 'logical' output-format = 'xml-platform' version = '1.0'>
<entity name='aes_subproject'>
<attribute name='aes_subprojectid'/>
<attribute name='aes_name'/>
<attribute name='createdon'/>
<attribute name='aes_subnumber_subproject'/>
<order descending='false' attribute = 'aes_name'/>
<filter type='and'>
<condition attribute='aes_subnumber_subproject' operator='not-null'/>
</filter>
<link-entity name='opportunity' alias='ad' link-type='inner' to='aes_opportunyid' from='opportunityid'>
<filter type='and'>
<condition attribute='opportunityid' operator='eq' value= "+ "'" + objTarget.Id.ToString() + "'" + @"' uitype='opportunity' uiname=''/>
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection subProjectrecords = service.RetrieveMultiple(new FetchExpression(fetchXmlString));
throw new InvalidPluginExecutionException("after subprojectrecords");
if ((EntityCollection)subProjectrecords != null)
{
updateRecord(subProjectrecords, objTarget, tracingService, service);
}
}
}
catch (Exception ex)
{
throw new FaultException(ex.Message);
}
}
}