• Krishna1317
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 16
    Replies

Hi All,

 

I have created a trigger on attachment. When I run it, it is giving an errror tht attachment body cannot be null.

 

trigger CTC_AttachmentDelete on Attachment (after delete) {

public list<Attachment> errorAttachments = new list<Attachment>();
public list<Attachment> updateAttachments = new list<Attachment>();
public list<CaseHistory> caseHistoryList = new list<CaseHistory>();

// Get the current user's profile name
Profile prof = [select Name from Profile where Id = :UserInfo.getProfileId() ];

// If current user is not a System Administrator, do not allow Attachments to be deleted
if (!'System Administrator'.equalsIgnoreCase(prof.Name)) {
for (Attachment a : Trigger.old) {
a.addError('You do not have permission to delete attachments.');
//page.addmesage();
}
}
else{

for(Attachment a : Trigger.old){

try{
//CaseHistory ch = new CaseHistory();
//ch.CaseId = a.ParentId;
//caseHistoryList.add(ch);

Deleted_Attachments__c dAttach = new Deleted_Attachments__c();
dAttach.Case__c = a.ParentId;

system.debug('case history list before insert is: '+dAttach);
insert dAttach;

Attachment attach=new Attachment();
Blob bodyString = a.Body;
attach.Body=bodyString;
attach.Name=a.Name;
attach.ContentType=a.contentType;
attach.ParentID=dAttach.Id;

system.debug('attachment before insert: '+attach+' old attachment is: '+a);
insert attach;

delete a;
}

catch(DmlException dex){
system.debug('exception while deleting attachment'+ dex);
}
}

/**if(caseHistoryList.size()>0){

try{
system.debug('case history list before insert is: '+caseHistoryList);
insert caseHistoryList;
}
catch(exception ex){
system.debug('error that occured while inserting caseHistoryList: '+ex);
}

}**/

}
}

HI,

 

I tried to use the detail tag in sites and tried to get account detail and it is not showing the detail. The account is customer/prospect.. Below is my code

 

<

apex:page standardcontroller="Account" extensions="AccountDisplayController" sidebar="false" >

 

<apex:variable var="acc" value="{!currentAcc}" />

 

<apex:form >

<apex:outputpanel rendered="true">

<apex:detail subject="{!acc.Id}" relatedList="true" rendered="true" showChatter="true" title="true"/>

 

</apex:outputpanel>

 

</apex:form>

 

 

</apex:page>

 

*****************************************

 

public

classAccountDisplayController {

 

public string lpidValue = ApexPages.currentPage().getParameters().get('lValue');

 

publiclist<Account> accList{get;set;}

 

publicAccountcurrentAcc;

 

publicAccountDisplayController(ApexPages.StandardController controller){

 

list<Account> accl = getAccDetails();

currentAcc = accl[0];

}

publiclist<Account> getAccDetails(){

 

accList = [

SELECTName, Phone FromAccountWHERELegal_Person_id__c =:lpidValue ];

 

//currentAcc = accList[0];//system.debug('account in getAccDetails: '+currentAcc);returnaccList;

 

}

publicAccountgetcurrentAcc(){

 

system.debug('account in getcurrentAcc(): '+currentAcc);

 

returnthis.currentAcc;

}

 

}

 

 

Hi,

 

Can anyone tell me how to get the xml schema of salesforce objects currently existing in the services cloud of my organisation. Can anyone tell me if using sforceHerder is safe?

Hi,

 

I have a products object which has product family as picklist and products as text field. In the visual force page, is it possible to do ajax kind of autofillup the products related to a family, if a family is selected? The product family will be a dropdown and the product will be a text box

 

Pls help.

 

 I am trying to consume the webservice hosted on http://xx.x.x.xxx/sfdc/AccountService.svc .

When I am  parsing  the wsdl into SFDC. It gives me an error.. Error: Failed to parse wsdl: Parse error: Found invalid XML. processing instruction can not have PITarget with reserveld xml name (position: START_DOCUMENT seen \r\n

Please help me to fix this..

Appreciate any inputs.

Thanks

I've had some developer false starts and hoping to find a committed hacker to help me at the hackathon. I have an idea with commercial potential, let me know if you're interested. Ping me directly and we can chat before Mon Nov 18 to see if you like what I'm thinking.

  • November 13, 2013
  • Like
  • 0

I've an idea but due to last minute changes; no team.  Anyone ready to hack; looking for inspiration -- give me a shout. 

Hi All,

 

I have created a trigger on attachment. When I run it, it is giving an errror tht attachment body cannot be null.

 

trigger CTC_AttachmentDelete on Attachment (after delete) {

public list<Attachment> errorAttachments = new list<Attachment>();
public list<Attachment> updateAttachments = new list<Attachment>();
public list<CaseHistory> caseHistoryList = new list<CaseHistory>();

// Get the current user's profile name
Profile prof = [select Name from Profile where Id = :UserInfo.getProfileId() ];

// If current user is not a System Administrator, do not allow Attachments to be deleted
if (!'System Administrator'.equalsIgnoreCase(prof.Name)) {
for (Attachment a : Trigger.old) {
a.addError('You do not have permission to delete attachments.');
//page.addmesage();
}
}
else{

for(Attachment a : Trigger.old){

try{
//CaseHistory ch = new CaseHistory();
//ch.CaseId = a.ParentId;
//caseHistoryList.add(ch);

Deleted_Attachments__c dAttach = new Deleted_Attachments__c();
dAttach.Case__c = a.ParentId;

system.debug('case history list before insert is: '+dAttach);
insert dAttach;

Attachment attach=new Attachment();
Blob bodyString = a.Body;
attach.Body=bodyString;
attach.Name=a.Name;
attach.ContentType=a.contentType;
attach.ParentID=dAttach.Id;

system.debug('attachment before insert: '+attach+' old attachment is: '+a);
insert attach;

delete a;
}

catch(DmlException dex){
system.debug('exception while deleting attachment'+ dex);
}
}

/**if(caseHistoryList.size()>0){

try{
system.debug('case history list before insert is: '+caseHistoryList);
insert caseHistoryList;
}
catch(exception ex){
system.debug('error that occured while inserting caseHistoryList: '+ex);
}

}**/

}
}

HI,

 

I tried to use the detail tag in sites and tried to get account detail and it is not showing the detail. The account is customer/prospect.. Below is my code

 

<

apex:page standardcontroller="Account" extensions="AccountDisplayController" sidebar="false" >

 

<apex:variable var="acc" value="{!currentAcc}" />

 

<apex:form >

<apex:outputpanel rendered="true">

<apex:detail subject="{!acc.Id}" relatedList="true" rendered="true" showChatter="true" title="true"/>

 

</apex:outputpanel>

 

</apex:form>

 

 

</apex:page>

 

*****************************************

 

public

classAccountDisplayController {

 

public string lpidValue = ApexPages.currentPage().getParameters().get('lValue');

 

publiclist<Account> accList{get;set;}

 

publicAccountcurrentAcc;

 

publicAccountDisplayController(ApexPages.StandardController controller){

 

list<Account> accl = getAccDetails();

currentAcc = accl[0];

}

publiclist<Account> getAccDetails(){

 

accList = [

SELECTName, Phone FromAccountWHERELegal_Person_id__c =:lpidValue ];

 

//currentAcc = accList[0];//system.debug('account in getAccDetails: '+currentAcc);returnaccList;

 

}

publicAccountgetcurrentAcc(){

 

system.debug('account in getcurrentAcc(): '+currentAcc);

 

returnthis.currentAcc;

}

 

}

 

 

Hi,

 

I need to construct a CSV file with APEX and am a bit new to this cloud computing.

Do you have any sample code I could get started with that, or a resources that you can point me to develop and generate a  CSV File to send through the Email??

 

Can this be achieved in salesforce by any Way?

  • December 29, 2011
  • Like
  • 0

I want to add a button on edit page of a record (say button which opens an external URL in a new window, may be a a url for reference). How do I achieve so?


There's always option of overriding with visualforce page, but there's lot of pitfalls around that approach (say a new recordtype or field is added, you need to create new visualforcce page or update the page respectively etc)

Any idea on how to achieve this? 

 

Chirag

Hi,

 

Can anyone tell me how to get the xml schema of salesforce objects currently existing in the services cloud of my organisation. Can anyone tell me if using sforceHerder is safe?

I have created a dashborad which contains few reports. I have created few roles. One role is for viewer who can only view the dashboards and the other one is for developer who can edit the reports.

Than I have created few users and given them the access to the dashboards, but when they logged in into the sales force, they were not able to see the dashboards.

Any help, what may be missing.

I have a custom button that does some basic logic and then returns the user to the contract view page.  It puts the user at the top of the contract page but i would like if it can make the page load right at the related list section.  (An example of how this works is when you go to a wikipeida page and click on a Table of contents hyperlink).

 

Does anyone know how you can do this?  (maybe with the hash # symbol)

Hi all,

 

We lend Demo-Products to our customers by a certain time period with a lot of date fields.

(delivery date to customer, arrival date at customer, delivery date back to us, arrival date back to us, ...)

 

I need a report that gives a overview over all Demo-Products, which shows where is a Product at certain point of time.

I can not present it in a well readable presentation with Salesforce standard tools.

 

Is there any possibility to create reports with Apex or extend Salesforce customized reports with Apex.

 

Thanks!