• Ibt
  • NEWBIE
  • 0 Points
  • Member since 2011

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

        I designed a visual force page to display list of opportunity attachments. It's displaying opporunities with remove link also. Written onclick event of remove link. Onclick of the link, javascript function is calling and displaying alert of attachment id. Used <apex:actionFunction> for this and defined oncomplete attribute also, in that  alert is given. This alert also displaying onclick of remove link but deleteAttachment() apex method is not calling(It contains logic to delete attachment). Please guide me if any thing wrong in code.

 

Visual force page:

 

<apex:page controller="SendController">

 

<script>
function deleteAttach(attachmentId) {
alert('Entered Javascript With Id' + attachmentId) ;
deleteAttachment(attachmentId);
}
</script>


<apex:form enctype="multipart/form-data" id="frm">
<apex:actionFunction name="deleteAttachment" action="{!deleteAttachment}" oncomplete="alert('ok');">
<apex:param name="attachmentId" assignTo="{!attachmentId}" value=""/>
</apex:actionFunction>

-------------

 

<apex:repeat value="{!attResults}" var="attResult">
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, attResult.id)}" target="_blank">
{!attResult.name}
</apex:outputLink>
&nbsp;&nbsp;&nbsp;
<apex:outputLink onclick="deleteAttach('{!attResult.id}');" >
Remove
</apex:outputLink>
<br/>
</apex:repeat>

-----

 

</apex:form>

</apex:page>

 

 

Apex class:

 

public class SendController {  

 

public List<Attachment> attResults {get; set;}

 

public SendController() {
System.debug('Inside SendWithSutiSign constructor');

attResults = [select Id, Name from Attachment Where ParentId = :id];         

}

 

public String attachmentId {get; set;}
public void deleteAttachment() {
System.debug('Inside deleteAttachment method');
try {
System.debug('Attachment Id1=>' + attachmentId);
System.debug('Attachment Id1=>' + Apexpages.currentPage().getParameters().get('firstParam'));
Attachment attc = [select Id, Name from Attachment Where Id = :attachmentId];
delete attc;
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment deleted successfully'));

//Get attachment list of opportunity
attResults = [select Id, Name from Attachment Where ParentId = :id];
} catch (DMLException e) {
System.debug('Exception in deleteAttachment method');
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error deleteing attachment'));
}
}

}

 

 

Thanks in advance.

  • May 22, 2013
  • Like
  • 0

Can any body please tell me that Is there any wary to get custom object records from salesforce database to my web application? If yes, please provide links.

  • May 14, 2013
  • Like
  • 0

I implemented partner and metadata wsdls and Iam able to get list of custom objects also. Can anybody provide help to get records from cutsom object to my application?

 

  • May 02, 2013
  • Like
  • 0

Hi,

 

        I have created two views(view1, view2) using "Create New View" link provided in contacts list page at salesforce. I have done integration with salesforce (partner and metadata wsdls) to web application through JAX-WS. Iam able to get contacts using partner wsdl. As of I know that the created views are storing in ListViews object. To retrieve these views, I am using metadata api. When I use the following code, Iam not able to get my created views(view1, view2).

 

ListMetadataQuery query = new ListMetadataQuery();
query.setType("CustomObject");
List<ListMetadataQuery> queries = new ArrayList();
queries.add(query);
double asOfVersion = 27.0;
List<FileProperties> lmr = metadataCoonnection.listMetadata(queries, asOfVersion);
if (lmr != null) {
    for (FileProperties n : lmr) {
        System.out.println("Component fullName: " + n.getFullName());
        System.out.println("Component type: " + n.getType());
    }
}

 

 

 

Is my approch wrong or Is any mistake in code?

Thanks in advance for any help.

 

Thanks & Regards

Kumar

  • May 02, 2013
  • Like
  • 0

Hi,

 

        I have created two views(view1, view2) using "Create New View" link provided in contacts list page at salesforce. I have done integration with salesforce (partner and metadata wsdls) to web application through JAX-WS. Iam able to get contacts using partner wsdl. As of I know that the created views are storing in ListViews object. To retrieve these views, I am using metadata api. When I use the following code, Iam not able to get my created views(view1, view2).

 

ListMetadataQuery query = new ListMetadataQuery();
query.setType("CustomObject");
List<ListMetadataQuery> queries = new ArrayList();
queries.add(query);
double asOfVersion = 27.0;
List<FileProperties> lmr = metadataCoonnection.listMetadata(queries, asOfVersion);
if (lmr != null) {
    for (FileProperties n : lmr) {
        System.out.println("Component fullName: " + n.getFullName());
        System.out.println("Component type: " + n.getType());
    }
}

 

Is my approch wrong or Is any mistake in code?

Thanks in advance for any help.

 

Thanks & Regards

Kumar

  • May 01, 2013
  • Like
  • 0

Can any body please tell me that Is there any wary to get custom object records from salesforce database to my web application? If yes, please provide links.

  • May 14, 2013
  • Like
  • 0

I implemented partner and metadata wsdls and Iam able to get list of custom objects also. Can anybody provide help to get records from cutsom object to my application?

 

  • May 02, 2013
  • Like
  • 0