+ Start a Discussion
chrismclarenchrismclaren 

S-Control to create new opportunity from product and delete product

I am trying to create an s-control that, from an opportunity product, will create a new opportunity and then delete the opportunity product.  I have managed to get it to create a new opportunity but I am having trouble getting ti to delete the product,
 
This is the code I currently have :-
 
<script type="text/javascript">
window.parent.location.href="{!URLFOR($Action.Opportunity.New
,Opportunity.Id, [opp3=Opportunity.Name , opp7=  OpportunityLineItem.TotalPrice  ])};"
  ({!$Action.OpportunityLineItem.Delete}), {!$ObjectType.OpportunityLineItem})

</script>
 
Unfortunately this currently bring up nothing, but if I take away "  ({!$Action.OpportunityLineItem.Delete}), {!$ObjectType.OpportunityLineItem})" it bring up the new opportunity page but obviously does not delete the product.  Any suggestions???
Ron HessRon Hess
once the location.href executes, your script no longer has context, the remaining lines are never run.  You find yourself in a new browser location and the Delete that you wanted to run is tossed away.

you will probably have to use two scontrols , one to create the opp, one to delete the product.

or you can use an scontrol that takes advantage of the API to create the opp, delete the product , then "goto" the newly created opp (do this last.)