cancel
Showing results for 
Search instead for 
Did you mean: 

Can't Create Notes for Account using CAS

Former Member
0 Kudos

Hi,

Good day!

I'm trying to create an action wherein I want to copy the Notes from a Visit to the Notes of an Account. My code for the OnSave of Visit extension is below:

var qCustomer = Customer.QueryByIdentification;
var selCustomer = qCustomer.CreateSelectionParams();
selCustomer.Add(qCustomer.InternalID,"I","EQ", vPartyID);
var tCustomer = qCustomer.Execute(selCustomer);
var sCustomer = tCustomer.GetFirst();
//get text from visit text collection
var vTextCollection = this.TextCollection.Text.GetFirst();
var vText = vTextCollection.TextContent.FormattedText.content;
//create new text note for customer
var newCollection = sCustomer.TextCollection.Create();
elCText.TypeCode.content = "10034";
var newContent = sCustomer.TextCollection.Text.Create(elCText);
elCTextContent.FormattedText.content = vText;
newContent.TextContent.Create(elCTextContent);

On debug mode, I don't encounter any error but I get a report incident error once the lines above are executed.

What might be missing for the above?

Thanks in Advance!

Marc Hirang

Accepted Solutions (1)

Accepted Solutions (1)

may_thitsaoo
Contributor
0 Kudos

Hi Marc Hirang,


Please try with this.

var newCollection = sCustomer.TextCollection.Create();

elCText.TypeCode.content = "10034";

var newContent = newCollection.Text.Create(elCText);

var elCTextContent = newContent.TextContent.Create();

elCTextContent.Text.content = vText;


Regards,

May

Former Member
0 Kudos

Hi May,

Issue still persist on my side. Do you think I should raise this now as an incident?

Thanks and Regards,

Marc

may_thitsaoo
Contributor
0 Kudos

Hi Marc,

Yeah its strange. We are ok with that code.

Have you tried to debug it?

Regards,

May

Former Member
0 Kudos

I need to add an if statement to make sure that Customer TextCollection is set.

if(sCustomer.TextCollection.IsSet()){
	elCText.TypeCode.content = "10034";
	var newContent = sCustomer.TextCollection.Text.Create(elCText);
	var vCTextContent = newContent.TextContent.Create();
	vCTextContent.FormattedText.content = vTextCollection.TextContent.FormattedText.content;
}else{
	var newCollection = sCustomer.TextCollection.Create();
	elCText.TypeCode.content = "10034";
	var newContent = newCollection.Text.Create(elCText);
	var vCTextContent = newContent.TextContent.Create();
	vCTextContent.FormattedText.content = vTextCollection.TextContent.FormattedText.content;
}

Answers (0)