USP_DATAFORMTEMPLATE_ADD_INDTOGROUP_RELATIONSHIP
The save procedure used by the add dataform template "Relationship Individual to Group Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@CONSTITUENTID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@RECIPROCALCONSTITUENTID | uniqueidentifier | IN | Related constituent |
@RECIPROCALTYPECODEID | uniqueidentifier | IN | Constituent group is the |
@RELATIONSHIPTYPECODEID | uniqueidentifier | IN | Constituent is the |
@STARTDATE | datetime | IN | Start date |
@ENDDATE | datetime | IN | End date |
@COMMENTS | nvarchar(max) | IN | Comments |
@PRIMARYSOFTCREDITRELATIONSHIPEXISTS | bit | IN | Apply to <Constituent> for revenue from <Reciprocal> |
@PRIMARYSOFTCREDITMATCHFACTOR | decimal(5, 2) | IN | Recognition credit match percent |
@RECIPROCALSOFTCREDITRELATIONSHIPEXISTS | bit | IN | Apply to <Reciprocal> for revenue from <Constituent> |
@RECIPROCALSOFTCREDITMATCHFACTOR | decimal(5, 2) | IN | Recognition credit match percent |
@PRIMARYRECOGNITIONTYPECODEID | uniqueidentifier | IN | Recognition credit type |
@RECIPROCALRECOGNITIONTYPECODEID | uniqueidentifier | IN | Recognition credit type |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_INDTOGROUP_RELATIONSHIP
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@CONSTITUENTID uniqueidentifier,
@RECIPROCALCONSTITUENTID uniqueidentifier = null,
@RECIPROCALTYPECODEID uniqueidentifier = null,
@RELATIONSHIPTYPECODEID uniqueidentifier = null,
@STARTDATE datetime = null,
@ENDDATE datetime = null,
@COMMENTS nvarchar(max) = null,
@PRIMARYSOFTCREDITRELATIONSHIPEXISTS bit = 0,
@PRIMARYSOFTCREDITMATCHFACTOR decimal(5,2) = 100,
@RECIPROCALSOFTCREDITRELATIONSHIPEXISTS bit = 0,
@RECIPROCALSOFTCREDITMATCHFACTOR decimal(5,2) = 100,
@PRIMARYRECOGNITIONTYPECODEID uniqueidentifier = null,
@RECIPROCALRECOGNITIONTYPECODEID uniqueidentifier = null
)
as
set nocount on;
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
if @ID is null
set @ID = newid();
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
begin try
declare @SETID uniqueidentifier = newid();
insert into dbo.RELATIONSHIPSET
(
ID,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@SETID,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
);
-- Check for constraints
if not exists(
select 1 from dbo.RELATIONSHIP
where RELATIONSHIPCONSTITUENTID=@CONSTITUENTID
and RECIPROCALCONSTITUENTID=@RECIPROCALCONSTITUENTID
and RELATIONSHIPTYPECODEID=@RELATIONSHIPTYPECODEID
and RECIPROCALTYPECODEID=@RECIPROCALTYPECODEID
)
and (@CONSTITUENTID <> @RECIPROCALCONSTITUENTID)
begin
insert into dbo.RELATIONSHIP
(
ID,
RELATIONSHIPCONSTITUENTID,
RECIPROCALCONSTITUENTID,
RELATIONSHIPTYPECODEID,
RECIPROCALTYPECODEID,
STARTDATE,
ENDDATE,
RELATIONSHIPSETID,
COMMENTS,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
@ID,
@CONSTITUENTID,
@RECIPROCALCONSTITUENTID,
@RELATIONSHIPTYPECODEID,
@RECIPROCALTYPECODEID,
@STARTDATE,
@ENDDATE,
@SETID,
@COMMENTS,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
);
exec dbo.USP_RELATIONSHIPCONFIGURATION_CONFIGURE
@CONSTITUENTID
,@RECIPROCALCONSTITUENTID
,@RELATIONSHIPTYPECODEID
,@RECIPROCALTYPECODEID
,@CHANGEAGENTID
,@CURRENTDATE
end
exec dbo.USP_RECOGNITIONDEFAULTSUPDATE @CONSTITUENTID, @RECIPROCALCONSTITUENTID,
@STARTDATE, @ENDDATE, @PRIMARYSOFTCREDITRELATIONSHIPEXISTS, @PRIMARYSOFTCREDITMATCHFACTOR,
@PRIMARYRECOGNITIONTYPECODEID, @RECIPROCALSOFTCREDITRELATIONSHIPEXISTS,
@RECIPROCALSOFTCREDITMATCHFACTOR, @RECIPROCALRECOGNITIONTYPECODEID, @CHANGEAGENTID;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;