Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7259 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

I have written a script that loops through a selection of records and sends out an email (using value of global fields as subject and body). I would like to keep a record of what email was sent to whom so I created a related table (related via an auto-generated, unmodifiable number field) to hold this information. Each time an email is sent I would like to automatically create a new record in the related table and fill it with the sequence number of the current record in the loop, the current date, and the subject of the email. I would then display these records via a portal. I thought I could call New Record/Request within the loop but don't see any way to specify the table. Can anyone help me out here? How would I do this?

TIA,

rlbryant

Posted

Your loop must work like this:

Go to portal row first

Loop

___Setings of necessary fields of email___

Go to portal row next(exot after last)

Endloop

Posted

Thanks for the reply. I'm not sure this will work. I need the related records to be created as I am looping through the set of parent records to send the emails. That is, the user finds a selection of records in the parent table and then the script loops through each one to send the email. I don't need to create more than one related record per parent record, so I don't need a loop for the portal records, just for the parent records. Also, I may not necessarily want the first portal row, just whatever portal row is next depending on how many related records have been created when previous emails were sent. I'll give this a try though to see what happens. Maybe the Go to portal row first line is what I need. Currently the script is sending the emails but the related records are not getting created.

Thank you for your help,

rlbryant

Your loop must work like this:

Go to portal row first

Loop

___Setings of necessary fields of email___

Go to portal row next(exot after last)

Endloop

Posted

At this case may be this will help you? Sorry if it isn't what you want.

Let Parent table have field Parent_Id. You must to create Parent_Id field in

EMails tabel, then create relation "Emails" on this field from Parent to EMails. After in Parent table you can create script

Go to record first

Loop

____Set Emails::Email_Text,"your text or textfield"

____Go to record next(exit after last)

endloop

Posted

OK, I've been scouring the forum for clues and I almost have this working. The portal records are getting created but the problem is they are not getting properly related because they are ALL getting the ID (i.e., key) of the first parent record. Here is the script. Can anyone tell me what I am doing wrong?

Go to Record/Request/Page [First]

Loop

Send Mail [No dialog; To: People_Contacts::Email_Address1; Subject: People_Contacts::Global_Email_Subject; Message: People_Contacts::Global_Email_Body]

Go to Layout ["Communications1" (Communications)]

New Record/Request

Set Field [Communications::PC_Sequence_Number; Get(ScriptParameter)]

Set Next Serial Value [Communications::Sequence_Number]

Set Field [Communications::Communication Type; "Email"]

Set Field [Communications::Subject; People_Contacts::Global_Email_Subject]

Insert Current Date [select; Communications::Sent]

Commit Records/Requests [No dialog]

Go to Layout [original layout]

Go to Record/Request/Page [Next; Exit after last]

End Loop

Thanks!

rlbryant

  • 2 weeks later...
Posted

It looks like you're missing part of your Set Next Serial Value step. You're specifying the field, but not the calculation to increment it. Also, what is the ScriptParameter? If it's the parent's key, then of course each new record will have the same foreign key, since the ScriptParameter never changes once the script is called.

Additionally, you don't need Insert Current Date. Set Field [Communications::Sent; Get(CurrentDate)] will work and is more reliable.

This topic is 7259 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.