USP_DATAFORMTEMPLATE_EDITLOAD_EXTENDEDRELATIONSHIP_NPALINKORGTOCONSTIT
The load procedure used by the edit dataform template "Extended Relationship Nonprofit Affiliation Link Organization To Constituent Edit Data Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter used to load the fields defined on the form. |
@DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. |
@TSLONG | bigint | INOUT | Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record. |
@CONSTITUENTID | uniqueidentifier | INOUT | Organization |
@COMPANY | nvarchar(100) | INOUT | Company name |
@LINE1 | nvarchar(150) | INOUT | Line 1 |
@CITY | nvarchar(30) | INOUT | City |
@STATEID | uniqueidentifier | INOUT | State ID |
@ZIP | nvarchar(10) | INOUT | Zip |
@PHONE | nvarchar(20) | INOUT | Phone |
@WEBSITE | UDT_WEBADDRESS | INOUT | Website |
@INFOSOURCECODEID | uniqueidentifier | INOUT | Info source code ID |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_EXTENDEDRELATIONSHIP_NPALINKORGTOCONSTIT(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@TSLONG bigint = 0 output,
@CONSTITUENTID uniqueidentifier = null output,
@COMPANY nvarchar(100) = null output,
@LINE1 nvarchar(150) = null output,
@CITY nvarchar(30) = null output,
@STATEID uniqueidentifier = null output,
@ZIP nvarchar(10) = null output,
@PHONE nvarchar(20) = null output,
@WEBSITE dbo.UDT_WEBADDRESS = null output,
@INFOSOURCECODEID uniqueidentifier = null output
)
as
set nocount on;
declare @CHANGEAGENTID uniqueidentifier
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
declare @DEFAULTCOUNTRYID uniqueidentifier;
exec @DEFAULTCOUNTRYID = dbo.UFN_COUNTRY_GETDEFAULT;
-- be sure to set these, in case the select returns no rows
set @DATALOADED = 0
set @TSLONG = 0
-- populate the output parameters, which correspond to fields on the form. Note that
-- we set @DATALOADED = 1 to indicate that the load was successful. Otherwise, the system
-- will display a "no data loaded" message. Also note that we fetch the TSLONG so that concurrency
-- can be considered.
select
@DATALOADED = 1,
@TSLONG = NPA.TSLONG,
@CONSTITUENTID = NPA.CONSTITUENTID,
@COMPANY = WP.DN_ORGANIZATION,
@LINE1 = WP.LINE1,
@CITY = WP.CITY,
@STATEID = (select top(1) ID from dbo.STATE where COUNTRYID = @DEFAULTCOUNTRYID and (DESCRIPTION = WP.STATE or ABBREVIATION = WP.STATE)),
@ZIP = WP.ZIP,
@WEBSITE = WP.WEBSITE,
@PHONE = WP.PHONE
from
dbo.WPNONPROFITAFFILIATION WP
left join
dbo.WPRELATIONSHIP_NPA NPA on WP.WPRELATIONSHIP_NPA_ID = NPA.ID
where WP.ID = @ID
select @INFOSOURCECODEID = ID from dbo.INFOSOURCECODE where DESCRIPTION = 'GuideStar'
if @INFOSOURCECODEID is null begin
insert into dbo.INFOSOURCECODE
(
DESCRIPTION,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED
)
values
(
'GuideStar',
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE
)
select @INFOSOURCECODEID = ID from dbo.INFOSOURCECODE where DESCRIPTION = 'GuideStar'
end
return 0;