nahidjamalli

Untitled

Dec 2nd, 2021
2,181
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.  
  49.   EXEC con_getNextRecId1 @newRecId OUTPUT;
  50.  
  51.   INSERT INTO WorkflowSteps (WorkflowId, EngagementStepType, Title, ParentWorkflowStepId, WorkspaceId, CreatorId, recId,
  52.   [STATUS], [DATE], [TIME], EmailToSendId, EmailName, AssignTo, [Hours], [Minutes], [Days], Weeks, Subject, QuestionField, QuestionYesOrNo, StageId, OpportunityName, MoveToStepId,
  53.   IsRepeatable, INTERVAL, IsConsent, UseDate, EmailType, OpportunityAmount, OpportunityCurrency, OpportunityStepType, AIID, TaskAssignedToId, TaskDescription, TaskScheduledDate, TaskSubject, MeetingAssignedToId, MeetingDescription, MeetingScheduledDate, MeetingPurpose, MeetingDuration)
  54.   OUTPUT INSERTED.Id
  55.     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);
  56.  
  57.   IF ((ISNULL(@AIID, 0) != 0)
  58.     AND (ISNULL(@EngagementId, 0) != 0))
  59.   BEGIN
  60.     UPDATE AI
  61.     SET ForwardToEngagementId = @EngagementId
  62.     WHERE Id = @AIID;
  63.   END
  64.  
  65.   IF (@WorkflowStepType = 7
  66.     AND @Title IS NULL)
  67.   BEGIN
  68.     SET @Title = @OpportunityName;
  69.   END
  70.  
  71.   EXEC con_AddWorkflowHistory @Title
  72.                              ,@WorkflowId
  73.                              ,@CreatorId
  74.                              ,'Added'
  75.                              ,@WorkflowStepType;
  76. END
  77. GO
RAW Paste Data