function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ArrowArrow 

Opportunity Button to add an attachment and update a field

We have KPIs on the opportunity dependent on Stage and Type and display red warnings in an S-Control.

 

All this is working well except for attachments.

 

The below custom button makes it easy for a user to add an attachment e.g. a proposal.

 

We track the number of attachments in a custom field (updated every 15 minutes from SQL Server) and compare this with the Attachment KPI field displaying a warning.

 

An issue with the above is that we still have a warning displayed for up to 15 minutes after they have added an attachment.

 

It is not possible in Salesforce to have Workflow or a trigger running reliably against the Attachment object.

 

I'm wondering whether there was a way to change the below URL in such a way so that it generated a field update in Salesforce on the opportunity. I could then use this update to hide the warning till the next SQL Server update.

 

 

 

/p/attach/NoteAttach?pid={!Opportunity.Id}&parentname={!Opportunity.Name}&retURL=%2F{!Opportunity.Id}

 

 

*werewolf**werewolf*

There is no way you could change that URL per se to do a field update on the opportunity.  You could change the button to an Execute Javascript button and use a technique like this to update something on the opportunity and then navigate the page to that URL afterwards.

Pradeep_NavatarPradeep_Navatar

You can write a trigger on Attachment using Eclipse. Open your Org in Eclipse then create a new trigger where you will get a picklist to select the Attachment Object. This is the way to write a trigger on Attachment.  Find below a sample code :

 

                trigger TiggerName on attachment(after insert)

                {         

                                attachment att  = Trigger.New[0];

                                // do here

                }