handlers/kapp_assignment_group_membership_lookup_v1/handler/init.rb
# Retrieves a record from CTM:People using the remedy_login_id parameter.  If
# there is an alternate approval assigned, it retrives the CTM:People record 
# associated to the alternate approver's remedy login id.  Alternate approvers
# are determinded using the get_approver() helper function.
#
# This is a required method that is automatically called by the Kinetic Task
# Engine.
#
# ==== Returns
# An Xml formatted String representing the return variable results.  
Retrieves a record from CTM:People using the remedy_login_id parameter.  If
there is an alternate approval assigned, it retrives the CTM:People record
associated to the alternate approver's remedy login id.  Alternate approvers
are determinded using the get_approver() helper function.

This is a required method that is automatically called by the Kinetic Task
Engine.

Returns
An Xml formatted String representing the return variable results.
Retrieves a record from CTM : People using the remedy_login_id parameter . If there is an alternate approval assigned it retrives the CTM : People record associated to the alternate approver ' s remedy login id . Alternate approvers are determinded using the get_approver () helper function . This is a required method that is automatically called by the Kinetic Task Engine . Returns An Xml formatted String representing the return variable results .
def execute()
    email_list = ''
	member_list = '<membership>'
	if (@parameters['assignee_id'])
		entry = @@remedy_forms['KAPP_Assignment_People'].find_entries(
		  :single,
		  :conditions => [%|'Login ID' = "#{@parameters['assignee_id']}" |],
		  :fields => ['Email']
		)
		email_list << entry['Email']
		member_list << '<member>'+ @parameters['assignee_id'] + '</member>'
	elsif (@parameters['support_group_id'])
		entry_list = @@remedy_forms['KAPP_Assignment_GroupAssoc_Lookup'].find_entries(
		  :all,
		  :conditions => [%|'Group ID' = "#{@parameters['support_group_id']}" |],
		  :fields => ['Login ID']
		)
		raise "No matching entries in the CTM:Support Group Association form for the given support group [#{@parameters['support_group_id']}]" if entry_list.nil?
		entry_list.each do |userid|
			entry = @@remedy_forms['KAPP_Assignment_People'].find_entries(
			  :single,
			  :conditions => [%|'Login ID' = "#{userid['Login ID']}" |],
			  :fields => ['Email']
			)
			if !entry.nil?
				if !entry['Email'].nil?
					email_list << entry['Email']+','
				end
			end
			if !userid['Login ID'].nil?
				member_list << '<member>'+ userid['Login ID'] + '</member>'
			end
		end      
		email_list = email_list.chomp(',')
    end
	member_list = member_list+'</membership>'
	puts("Results: email list: #{escape(email_list)}\n membership list: #{escape(member_list)}") if @debug_logging_enabled
    <<-RESULTS
    <results>
      <result name="Email List">#{escape(email_list)}</result>
	  <result name="Membership List">#{escape(member_list)}</result>
    </results>
    RESULTS
  end
def execute ( ) email_list = '' member_list = '<membership>' if ( @parameters [ 'assignee_id' ] ) entry = @@remedy_forms [ 'KAPP_Assignment_People' ] . find_entries ( :single , :conditions => [ %|'Login ID' = "#{@parameters['assignee_id']}" | ] , :fields => [ 'Email' ] ) email_list << entry [ 'Email' ] member_list << '<member>' + @parameters [ 'assignee_id' ] + '</member>' elsif ( @parameters [ 'support_group_id' ] ) entry_list = @@remedy_forms [ 'KAPP_Assignment_GroupAssoc_Lookup' ] . find_entries ( :all , :conditions => [ %|'Group ID' = "#{@parameters['support_group_id']}" | ] , :fields => [ 'Login ID' ] ) raise "No matching entries in the CTM:Support Group Association form for the given support group [#{@parameters['support_group_id']}]" if entry_list . nil? entry_list . each do | userid | entry = @@remedy_forms [ 'KAPP_Assignment_People' ] . find_entries ( :single , :conditions => [ %|'Login ID' = "#{userid['Login ID']}" | ] , :fields => [ 'Email' ] ) if ! entry . nil? if ! entry [ 'Email' ] . nil? email_list << entry [ 'Email' ] + ',' end end if ! userid [ 'Login ID' ] . nil? member_list << '<member>' + userid [ 'Login ID' ] + '</member>' end end email_list = email_list . chomp ( ',' ) end member_list = member_list + '</membership>' puts ( "Results: email list: #{escape(email_list)}\n membership list: #{escape(member_list)}" ) if @debug_logging_enabled <<-RESULTS 
    <results>
      <result name="Email List"> #{ escape ( email_list ) } </result>
	  <result name="Membership List"> #{ escape ( member_list ) } </result>
    </results>
     RESULTS end
Retrieves a record from CTM:People using the remedy_login_id parameter.
Retrieves a record from CTM : People using the remedy_login_id parameter .
# Build array containing the a list of approvers related to the Remedy support group # While excluding the requested by and requested for individuals    