protected override void Execute(CodeActivityContext codeActivityContext) { // Set up ITracingService, IOrganizationService. ITracingService tracingService = codeActivityContext.GetExtension <ITracingService>(); IWorkflowContext context = codeActivityContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = codeActivityContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); // Read InArguments. string recordUrl = RecordUrl.Get <string>(codeActivityContext); string appName = AppName.Get(codeActivityContext); // Create URL. string newRecordUrl = GenerateUrlForApp(service, recordUrl, appName); // Set OutArgument. NewRecordUrl.Set(codeActivityContext, newRecordUrl); }