| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CreateEdit ( | 
|   SWF_Step step | 
| ) id:Method_SWF_DialogCreateEditActivity_CreateEdit | 
| { | 
|   #keys: '[136682.0.604858867]' | 
|   Body: | 
|   [* | 
|     // Create new activity or edit activity | 
|      | 
|     currentdate := SWF_WorkflowDataset.GlobalParameter().CurrentDate(); | 
|     createdon := currentdate; | 
|     description := ""; | 
|     id := Key::ZeroKey(); | 
|     isdefaultopen := true; | 
|      | 
|     //set data for edit                                                                                                | 
|     if( not isnull( DataHolderOriginActivity.Data() ) ) | 
|     { | 
|       data := DataHolderOriginActivity.Data(); | 
|       id := data.ID() | 
|       isdefaultopen := data.IsDefaultOpen(); | 
|       description := EditFieldDescription.Text(); | 
|       createdon := data.CreatedOn(); | 
|        | 
|     } | 
|     else// set for new activity | 
|     { | 
|       id := SWF_WorkflowDataset.GetNewGlobalID();   | 
|        | 
|     //Auto set created time and created user name | 
|       description :=SWF_Translation::TRANSLATE_NewActivityCreatedBy( DateTime::Now(), SWF_WorkflowDataset.GetCurrentUser().Name() ) + String::NewLine() + EditFieldDescription.Text();   | 
|     } | 
|      | 
|     selectedelement := this.GetSelectionAuthorizationElement(); | 
|      | 
|     selected_authorization := SWF_AuthorizationBase::GetSelectedAuthorizationFromStringSelections( SWF_WorkflowDataset,DropDownStringListAssignedTo.Text(), | 
|                                                                                                    selectedelement ); | 
|                                                                                                    | 
|     step := DropDownListStep.Data(); | 
|      | 
|     service := SWF_WorkflowDataset.Service(); | 
|     service.TR_CreateUpdateActivity(  id, | 
|                                       EditFieldTitle.Text(), | 
|                                       description, | 
|                                       isdefaultopen, // user-created activities can still be linked to a step for the progress KPIs, but the status of the activity never depend on the step dependencies. | 
|                                       true, | 
|                                       DateTimeSelectorDueDate.DateTime().Date(), | 
|                                       createdon, | 
|                                       SWF_WorkflowDataset.GetCurrentUserID(), | 
|                                       guard( selected_authorization.DisplayName(), '' ), | 
|                                       ifexpr( isnull( step ), Key::ZeroKey(), step.ID() ), | 
|                                       guard( DataHolderOriginActivity.Data().ViewLink(), '' ), | 
|                                       guard( DropDownListView.Data().Id(), '' ) ); | 
|   *] | 
| } |