You need to sign in to do that
Don't have an account?
Gaurav Raj
Triggers
I am writing a trigger on dsfs__DocuSign_Status, i have written the following query
select id, (select id,name from attachments order by lastmodifieddate desc limit 1)
from dsfs__DocuSign_Status__c order by lastmodifieddate desc limit 1
how do i assign it to a variable, what datatype should i use for its execution?
i want to store the id of the attachement from the above query
this id i want to pass to a url
Hi,
You can try the following method,
Set<ID> attachID = new Set<ID>();
List<dsfs__DocuSign_Status__c> dsList = [Select id, (select id,name from attachments order by lastmodifieddate desc limit 1) from dsfs__DocuSign_Status__c order by lastmodifieddate desc limit 1];
if(dsList.size() > 0){
for(dsfs__DocuSign_Status__c ds : dsList){
attachID.add(ds.attachment__r.id); //Here you need to get the id of the attachment
}
}
Hope this helps you..!
Please don't forget to give kudos and mark this as a solution, if this works out.
hey thanx.
Can u help with the query to getting the id of the attachement.
how to append this id of the doc to salesforce's url?
Hi,
You can query the attachment id by using the following method,
Set<id> ids = new Set<id>();
for(Account a : Trigger.New){
ids.add(a.id);
Attachment atid = [SELECT id,name FROM Attachments WHERE ParentID IN: ids]; //This is the way to query attachmentid
}
If you want to append the attachement id to the salesforce url and you are using Apex controller and VF page, then following lines of code will help you,
public pagereference method1(){
Attachment atid = [SELECT id,name FROM Attachments WHERE ParentID =: <parent object ID>];
PageReference nextpage = new PageReference('/apex/Vfpagename?id='+atid);
return nextpage;
}
The line highlighted above will explain how to append your attachment id with pagereference
Hope this helps you...!
Please don't forget to give kudos and mark this as a solution, if this works out.