how to SetSaleType in crmscript afterSave

hi,

Problem is, there is object of NSSaleType i must set for the Type of current sale in Trigger afterSave, but I cannot load this object with my Type ID.

Integer typeID = 5;
NSSaleType saleType;
myNSSaleEntity.SetSaleType(saleType);
myNSSaleAgent.SaveSaleEntity(myNSSaleEntity);

 

Thanks!

RE: how to SetSaleType in crmscript afterSave

Hi,

Expect this to work;

Integer typeID = 5;
NSSaleType saleType;
saleType.SetId(typeId);
myNSSaleEntity.SetSaleType(saleType);
myNSSaleAgent.SaveSaleEntity(myNSSaleEntity);
By: Michel Krohn-Dale 20 Mar 2020

RE: how to SetSaleType in crmscript afterSave

Hi Michel,

Thanks, it works. Sorry, I should check it in Document.

by the way, I found there is unpossible to set Status in Sales BeforeSave Trigger:

ed.setOutputValue("SaleStatus", "2");

is it a bugs?

 

Thanks!

By: Jianchun You 20 Mar 2020

RE: how to SetSaleType in crmscript afterSave

Hi,

Think nature of how SaleEntity works is based on SaleEntity.Rating.Id, so if you instead use this ;

EventData ed = getEventData();
String status = "2";
/* sold-> status = "-2" lost-> status = "-1" */
ed.setOutputValue("SaleEntity.Rating.Id", status);
By: Michel Krohn-Dale 20 Mar 2020

RE: how to SetSaleType in crmscript afterSave

Yes, it works to set -1, -2 in Rating for Status Lost/Sold.

Thanks!

By: Jianchun You 20 Mar 2020