I could send you some of it, but I've added a logging function at the end, which gets executed. So the code runs fine.
This is the gist of it (though I removed some procedures that require dependencies on my code:
public class MoveRecord : RecordActionType { #region Constructor
public MoveRecord() { this.Description = "Verplaats de Record data naar het geselecteerde formulier. Let op: Formulier velden moeten 1 op 1 overeen komen."; this.Icon = "edit.png"; this.Id = new Guid("86645608-01a9-48bc-a5c9-91dbe445d9b1"); this.Name = "Verplaats Record"; }
#endregion
#region Public Methods
public override RecordActionStatus Execute(Record record, Form form) { using (Entities ctx = new Entities()) { if (ListForms != "") { #region Copy Record to Training Inschrijving //Copy information to Training var recordStorage = new RecordStorage(); var formStorage = new FormStorage(); var SelectedForm = formStorage.GetForm(new Guid(ListForms)); var recordServiceNew = new RecordService(SelectedForm); recordServiceNew.Open();
//Create new Record in Training Form var NewRecord = recordServiceNew.Record; NewRecord.IP = record.IP; NewRecord.MemberKey = record.MemberKey; NewRecord.CurrentPage = record.CurrentPage; NewRecord.UmbracoPageId = record.UmbracoPageId; NewRecord.Form = SelectedForm.Id; NewRecord.State = FormState.Submitted; recordStorage.InsertRecord(NewRecord, SelectedForm);
//Create Empty RecordFields in New Form Dictionary<int, string> CaptionList = new Dictionary<int, string>(); int CaptionCounter = 0; foreach (var field in SelectedForm.AllFields) { Guid key = Guid.NewGuid(); RecordField recordField = new RecordField() { Field = field, Key = key, Record = NewRecord.Id, Values = new List<object>() };
CaptionList.Add(CaptionCounter, field.Caption);
var recordFieldStorage = new RecordFieldStorage(); recordFieldStorage.InsertRecordField(recordField); NewRecord.RecordFields.Add(key, recordField); recordFieldStorage.Dispose();
CaptionCounter++; }
//Copy Info From Old Form foreach (KeyValuePair<Guid, RecordField> rf in record.RecordFields) { //Select Fieldnumber in new Form with same caption string FieldName = CaptionList.Where(it => it.Value == rf.Value.Field.Caption).FirstOrDefault().Value;
//Only copy exisiting Fields if (FieldName != null) { Guid key = Guid.NewGuid(); var recordField = NewRecord.GetRecordField(FieldName);
//Check if Prevalue Guid try {
//Als veld een guid is, gaat het om een prevalue. Vul dan gewoon de string in. Guid gd = new Guid(rf.Value.Values[0].ToString());
List<object> li = new List<object>(); li.Add(rf.Value.ValuesAsString()); recordField.Values = li;
} catch { recordField.Values = rf.Value.Values; }
var recordFieldStorage = new RecordFieldStorage(); recordFieldStorage.UpdateRecordField(recordField); recordFieldStorage.Dispose(); } else { try { customFunctions.AddLogEntry("Contour Error", "Bij Training Entry verplaatsen werd van '" + RecordUser + "' dit veld niet meeverplaatst: '" + rf.Value.Field.Caption + "'. De inhoud was '" + rf.Value.ValuesAsString() + "'", 0, 0, "", ""); } catch { } } }
//Set To Approved or not if (Convert.ToBoolean(Approved) == true) NewRecord.State = FormState.Approved; else NewRecord.State = FormState.Submitted;
//Update Record recordStorage.UpdateRecord(NewRecord, SelectedForm); recordStorage.UpdateRecordXml(NewRecord, SelectedForm); #endregion
//Check if relation is already stored SettingsStorage ss = new SettingsStorage(); string RelatedGuid = ss.GetSetting(record.Id, "MoveRecordOldNewIds");
//Save Relation between old and new record if (string.IsNullOrEmpty(RelatedGuid)) ss.InsertSetting(record.Id, "MoveRecordOldNewIds", NewRecord.Id.ToString()); else ss.UpdateSetting(record.Id, "MoveRecordOldNewIds", NewRecord.Id.ToString());
//GET FORM NAME string FormString = ""; using (FormStorage frmStor = new FormStorage()) { Form frm = frmStor.GetForm(record.Form); if (frm != null) FormString = frm.Name; }
[Setting("Selecteer Training", description = "Selecteer de training waarnaar u dit record wilt verplaatsen", control = "Contour.Addons.FieldSettings.ListOfForms", assembly = "EFT.Contour.Addons")] public string ListForms { get; set; }
[Setting("Zet op 'Approved'", description = "Selecteer dit als je het record gelijk op approved status wilt zetten", control = "Umbraco.Forms.Core.FieldSetting.Checkbox")] public string Approved { get; set; }
[Setting("Omschrijving", description = "Omschrijving van betaling (Training, Webwinkel Product) LET OP: Leeglaten betekent oude Omschrijving bewaren.", control = "Umbraco.Forms.Core.FieldSetting.TextField")] public string Omschrijving { get; set; }
Recordset action succeeds but results in 403 permission denied page
Hi all,
Umbraco 6.1.x / Contour 3.0.26
I'm having issues with a custom record set action of mine. It concerns one with settings, so it runs from a dialog box.
After upgrading from Contour 3.0.17 to 3.0.26 it started doing this.
It results in the following error. Which appears to be a wrong redirect or something.
Does anyone know whats going on here? The Record Action does achieve it's intended result. So it's not an error.
Martin
Comment author was deleted
Hmm no changes have been made to record set actions, did you also upgrade Umbraco to a newer version?
I just heard from my client that he's receiving that error for a few years now.
So it's not due to upgrading or contour versions.
I did upgrade from 4.7.2 to 6.1. Some time last year.
Comment author was deleted
Ok :) well hard to pinpoint then, would you mind sending the code for the action then I can test it locally and see what the issue is
Hi Tim,
I could send you some of it, but I've added a logging function at the end, which gets executed. So the code runs fine.
This is the gist of it (though I removed some procedures that require dependencies on my code:
is working on a reply...