nahidjamalli

Untitled

Dec 2nd, 2021
2,060
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE dbo.con_AddEngagementStep_6 @WorkflowId INT,
  2. @WorkflowStepType INT,
  3. @Title NVARCHAR(50),
  4. @ParentWorkflowStepId INT,
  5. @WorkSpaceId INT,
  6. @CreatorId INT,
  7. @YesStepId INT = NULL,
  8. @NoStepId INT = NULL,
  9. @STATUS NVARCHAR(200) = NULL,
  10. @DATE DATETIME = NULL,
  11. @TIME TIME = NULL,
  12. @EmailName NVARCHAR(200) = NULL,
  13. @AssignedTo INT = NULL,
  14. @EmailId INT = NULL,
  15. @Hours INT = NULL,
  16. @Minutes INT = NULL,
  17. @Days INT = NULL,
  18. @Weeks INT = NULL,
  19. @Subject NVARCHAR(200) = NULL,
  20. @QuestionField NVARCHAR(200) = NULL,
  21. @IsQuestionStepYes BIT = NULL,
  22. @StageId INT = NULL,
  23. @OpportunityName NVARCHAR(2000) = NULL,
  24. @MoveToStepId INT = NULL,
  25. @IsRepeatable BIT = NULL,
  26. @INTERVAL NVARCHAR(50) = NULL,
  27. @IsConsent BIT = NULL,
  28. @UseDate BIT = NULL,
  29. @EmailType TINYINT = 2,
  30. @OpportunityAmount DECIMAL(18, 2) = NULL,
  31. @OpportunityCurrency NVARCHAR(200) = N'GBP',
  32. @OpportunityStepType TINYINT = NULL,
  33. @AIID INT = NULL,
  34. @EngagementId INT = NULL,
  35. @TaskAssignedToId INT = NULL,
  36. @TaskDescription NVARCHAR(MAX) = NULL,
  37. @TaskScheduledDate DATETIME = NULL,
  38. @TaskSubject NVARCHAR(100) = NULL,
  39. @MeetingAssignedToId INT = NULL,
  40. @MeetingDescription NVARCHAR(MAX) = NULL,
  41. @MeetingScheduledDate DATETIME = NULL,
  42. @MeetingPurpose NVARCHAR(50) = NULL,
  43. @MeetingDuration INT = NULL
  44.  
  45. AS
  46. BEGIN
  47.   DECLARE @NewRecId BIGINT
  48.          ,@stepId INT;
  49.  
  50.   EXEC con_getNextRecId1 @newRecId OUTPUT;
  51.  
  52.   INSERT INTO WorkflowSteps (WorkflowId, EngagementStepType, Title, ParentWorkflowStepId, WorkspaceId, CreatorId, recId,
  53.   [STATUS], [DATE], [TIME], EmailToSendId, EmailName, AssignTo, [Hours], [Minutes], [Days], Weeks, Subject, QuestionField, QuestionYesOrNo, StageId, OpportunityName, MoveToStepId,
  54.   IsRepeatable, INTERVAL, IsConsent, UseDate, EmailType, OpportunityAmount, OpportunityCurrency, OpportunityStepType, AIID, TaskAssignedToId, TaskDescription, TaskScheduledDate, TaskSubject, MeetingAssignedToId, MeetingDescription, MeetingScheduledDate, MeetingPurpose, MeetingDuration)
  55.   OUTPUT INSERTED.Id
  56.     VALUES (@WorkflowId, @WorkflowStepType, @Title, @ParentWorkflowStepId, @WorkspaceId, @CreatorId, @NewRecId, @STATUS, @DATE, @TIME, @EmailId, @EmailName, @AssignedTo, @Hours, @Minutes, @Days, @Weeks, @Subject, @QuestionField, @IsQuestionStepYes, @StageId, @OpportunityName, @MoveToStepId, @IsRepeatable, @INTERVAL, @IsConsent, @UseDate, @EmailType, @OpportunityAmount, @OpportunityCurrency, @OpportunityStepType, @AIID, @TaskAssignedToId, @TaskDescription, @TaskScheduledDate, @TaskSubject, @MeetingAssignedToId, @MeetingDescription, @MeetingScheduledDate, @MeetingPurpose, @MeetingDuration);
  57.  
  58.   SET @stepId = SCOPE_IDENTITY();
  59.  
  60.   UPDATE WorkflowSteps
  61.   SET ParentWorkflowStepId = @stepId
  62.   WHERE ParentWorkflowStepId = @ParentWorkflowStepId
  63.   AND Id <> @stepId
  64.   AND WorkflowId = @WorkflowId;
  65.  
  66.  
  67.   IF ((ISNULL(@AIID, 0) != 0)
  68.     AND (ISNULL(@EngagementId, 0) != 0))
  69.   BEGIN
  70.     UPDATE AI
  71.     SET ForwardToEngagementId = @EngagementId
  72.     WHERE Id = @AIID;
  73.   END
  74.  
  75.   IF (@WorkflowStepType = 7
  76.     AND @Title IS NULL)
  77.   BEGIN
  78.     SET @Title = @OpportunityName;
  79.   END
  80.  
  81.   EXEC con_AddWorkflowHistory @Title
  82.                              ,@WorkflowId
  83.                              ,@CreatorId
  84.                              ,'Added'
  85.                              ,@WorkflowStepType;
  86. END
  87. GO
RAW Paste Data