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
CharlesDCharlesD 

Insert a sales team member within an s-control?

Hi Has anyone been able to add a sales team member with an s-control? Obviously you can't initalize a sales team object and then append field values, so how would you do this? Please advise thanks! I just thought though, is the only way to go to the Add Sales Team member page via the s-control and adding the field values in the URL and then having it save, all automatically? Is that the only way? Thanks!
sfdcfoxsfdcfox

You can add sales team members via an S-Control by using the following type of code:

Code:

<script type="text/javascript" src="/soap/ajax/11.0/connection.js">
</script>
<script language="JavaScript">
OTM = new sforce.SObject('OpportunityTeamMember')
OTM['OpportunityAccessLevel'] = 'Edit'
OTM['OpportunityId'] = '{!Opportunity.Id}'
OTM['TeamMemberRole'] = 'Account Executive'
OTM['UserId'] = '{$User.Id}'
results = sforce.connection.create([OTM])
if(!results[0].getBoolean('success'))
  alert('Could not add team member')
</script>


 

Of course, feel free to change the user ID, team member role, etc, as necessary.