• Andrew84
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

Is there a way to delete records with apex by passing only the id? I see that you can use the API by sending an ID[] array, but I'm not sure how to use that through Apex. 

 

This should explain what I'm attempting to do... 

public void deleteRecords() {
	list<Id> ids;
	// add an account
	ids.add('001____________');
	// add a contact
	ids.add('003____________');
	// add a custom object
	ids.add('a0Y____________');
	// delete them all
	delete(ids);
}

I've been trying to find a solution for this all over with no luck. I'm trying to create a GoToMeeting meeting from Salesforce through the GoToMeeting API. I'm not too familiar with APIs in general.

 

I get the error:

Argument cannot be null. Error is in expression '{!createMeeting}' in component <apex:page> in page gotomeetingapi

 

This is what I have on my Page:

 

<apex:page controller="GoToMeetingAPI">
    <apex:form id="newmeetings">
    	<script type="text/javascript">
	function addMeeting() {
		makeMeeting(
			document.getElementById("subject").value,
			document.getElementById("starttime").value,
			document.getElementById("endtime").value,
			document.getElementById("conferencecallinfo").value,
			document.getElementById("meetingtype").value
			);
		}
	</script> 
    	<apex:actionFunction name="makeMeeting" action="{!createMeeting}">
		<apex:param name="subject" value="t" />
		<apex:param name="starttime" value="" />
		<apex:param name="endtime" value="" />
		<apex:param name="conferencecallinfo" value="" />
		<apex:param name="meetingtype" value="" />
	</apex:actionFunction>
    	subject<input type="text" id="subject"/><br />
    	starttime<input type="text" id="starttime"/><br />
    	endtime<input type="text" id="endtime"/><br />
    	conferencecallinfo<input type="text" id="conferencecallinfo"/><br />
    	meetingtype<input type="text" id="meetingtype"/><br />
    	<button type="button" onclick="addMeeting()">Submit</button>
    </apex:form>
</apex:page

 

This what I have for my class:

 

public class GoToMeetingAPI {
	public PageReference createMeeting() {
		String subject = Apexpages.currentPage().getParameters().get('subject');
		String starttime = Apexpages.currentPage().getParameters().get('starttime');
		String endtime = Apexpages.currentPage().getParameters().get('endtime');
		String conferencecallinfo = Apexpages.currentPage().getParameters().get('conferencecallinfo');
		String meetingtype = Apexpages.currentPage().getParameters().get('meetingtype');
		Http httpProtocol = new Http();
		HttpRequest request = new HttpRequest();
		HttpResponse response = new HttpResponse();
		request.setEndpoint('https://api.citrixonline.com/G2M/rest/meetings');
		request.setMethod('POST');
		request.setBody('subject='+EncodingUtil.urlEncode(subject,'UTF-8')+
						'&starttime='+EncodingUtil.urlEncode(starttime,'UTF-8')+
						'&endtime='+EncodingUtil.urlEncode(endtime,'UTF-8')+
						'&passwordrequired=false'+
						'&conferencecallinfo='+EncodingUtil.urlEncode(conferencecallinfo,'UTF-8')+
						'&timezonekey=""'+
						'&meetingtype='+EncodingUtil.urlEncode(meetingtype,'UTF-8'));
		request.setHeader('Authorization','OAuth oauth_token=123456789');
		request.setCompressed(true);
		try {
            response = httpProtocol.send(request);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(response.toString());
        }
        return null;
	}
}

 I apologize for the names of my function names... I've been getting frustrated and all I need to do is show that it works.

 

The GET request was so much easier!

 

If anyone knows what I'm missing I'd be very appreciative.

Is there a way to delete records with apex by passing only the id? I see that you can use the API by sending an ID[] array, but I'm not sure how to use that through Apex. 

 

This should explain what I'm attempting to do... 

public void deleteRecords() {
	list<Id> ids;
	// add an account
	ids.add('001____________');
	// add a contact
	ids.add('003____________');
	// add a custom object
	ids.add('a0Y____________');
	// delete them all
	delete(ids);
}

Is there a way to add a button or something to a visualforce page that will allow a user to select other users to follow that record in chatter?  For example, I'm working a case and I want Bob to follow the case, so I'd click a button and a user lookup would popup, letting me select Bob and then add him as a follower to that record.

 

Thanks,

I've been trying to find a solution for this all over with no luck. I'm trying to create a GoToMeeting meeting from Salesforce through the GoToMeeting API. I'm not too familiar with APIs in general.

 

I get the error:

Argument cannot be null. Error is in expression '{!createMeeting}' in component <apex:page> in page gotomeetingapi

 

This is what I have on my Page:

 

<apex:page controller="GoToMeetingAPI">
    <apex:form id="newmeetings">
    	<script type="text/javascript">
	function addMeeting() {
		makeMeeting(
			document.getElementById("subject").value,
			document.getElementById("starttime").value,
			document.getElementById("endtime").value,
			document.getElementById("conferencecallinfo").value,
			document.getElementById("meetingtype").value
			);
		}
	</script> 
    	<apex:actionFunction name="makeMeeting" action="{!createMeeting}">
		<apex:param name="subject" value="t" />
		<apex:param name="starttime" value="" />
		<apex:param name="endtime" value="" />
		<apex:param name="conferencecallinfo" value="" />
		<apex:param name="meetingtype" value="" />
	</apex:actionFunction>
    	subject<input type="text" id="subject"/><br />
    	starttime<input type="text" id="starttime"/><br />
    	endtime<input type="text" id="endtime"/><br />
    	conferencecallinfo<input type="text" id="conferencecallinfo"/><br />
    	meetingtype<input type="text" id="meetingtype"/><br />
    	<button type="button" onclick="addMeeting()">Submit</button>
    </apex:form>
</apex:page

 

This what I have for my class:

 

public class GoToMeetingAPI {
	public PageReference createMeeting() {
		String subject = Apexpages.currentPage().getParameters().get('subject');
		String starttime = Apexpages.currentPage().getParameters().get('starttime');
		String endtime = Apexpages.currentPage().getParameters().get('endtime');
		String conferencecallinfo = Apexpages.currentPage().getParameters().get('conferencecallinfo');
		String meetingtype = Apexpages.currentPage().getParameters().get('meetingtype');
		Http httpProtocol = new Http();
		HttpRequest request = new HttpRequest();
		HttpResponse response = new HttpResponse();
		request.setEndpoint('https://api.citrixonline.com/G2M/rest/meetings');
		request.setMethod('POST');
		request.setBody('subject='+EncodingUtil.urlEncode(subject,'UTF-8')+
						'&starttime='+EncodingUtil.urlEncode(starttime,'UTF-8')+
						'&endtime='+EncodingUtil.urlEncode(endtime,'UTF-8')+
						'&passwordrequired=false'+
						'&conferencecallinfo='+EncodingUtil.urlEncode(conferencecallinfo,'UTF-8')+
						'&timezonekey=""'+
						'&meetingtype='+EncodingUtil.urlEncode(meetingtype,'UTF-8'));
		request.setHeader('Authorization','OAuth oauth_token=123456789');
		request.setCompressed(true);
		try {
            response = httpProtocol.send(request);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(response.toString());
        }
        return null;
	}
}

 I apologize for the names of my function names... I've been getting frustrated and all I need to do is show that it works.

 

The GET request was so much easier!

 

If anyone knows what I'm missing I'd be very appreciative.