SharePoint 2010 Workflow Update Lookup Field on Item - sharepoint-2010

I have a SharePoint Designer workflow in 2010. This workflow is associated with a list and when it is run, should copy the Current Item back into the list then update a field in that newly created item with a variable set at initiation of the workflow. Basically it duplicates an item then changes 1 value of the newly created item.
The field that I need to update is a lookup field into another list. For some reason SharePoint does not like this and errors out each time.
I have tried setting the value of the field to the following things, all of which fail when run.
ID of the lookup item
ID;#VALUE of the lookup item
VALUE of the lookup item
1;#201101 which is a hardcoded value I know is correct...just trying to test here
At this point, I am out of ideas. Can anyone help?
For more detail the workflow has 1 step with the following actions:
Copy item in Current Item to list at [Parameter:ListURL], Do no Overwrite existing items. Store resulting list item id in [Variable:DuplicateID].
then set [Variable:Reporting Month ID] to [Reporting Months:ID]. (this is a lookup into Reporting Months list using variable [Variable:Reporting Month] which is set at initiation of workflow).
then Update item in Current List (the item is determined by [Variable:DuplicateID] and I try to set the value of the Reporting Month field in Current List using various combinations [Variable:Reporting Month ID] and [Variable:Reporting Month]
The error I get when the worflow is run is below.
The workflow could not update the item, possibly because one or more columns for the item require a different type of information.

Have had now the same problem and it seems that this is an spd-bug. I also wanted to write back the "variable: create" with the id of the destination-item into the lookup-field in the target-list. I also got always the same error. have checked the value also by updating a comment-field with this value and it was an integer value. but I could not update the lookup-value.
My solution for it:
Create a second workflow in the destination list that "update list item" in the target-list (update the lookup-value with the id of the current item) and define that the workflow starts automaticly by creation.
That worked fine for me. It needed some seconds more till the lookup-value was visible but this was not a problem for me.

Related

How do I validate a Form input field with a Table row value in microsoft access?

I am having issues with setting a Validation rule in Access.
I have a database with the tables Clients, TypeClient, Sales, SalesList, Items.
I have a form for Sales, with a sub-form SalesList inside which has a relationship with Items in order for me to put several stock items in Sales instead of only one item.
Inside Sales table is ID, Date Sold, ID Client.
Inside SalesList is ID_List(referenced to ID in Sales), ID_Item(referenced to ID in Items), Quantity.
Inside Items is ID, Name, Stock(how much we have in stock), Price
The issue is that I am trying to validate the data I enter in the sub-form Quantity field to be higher than 0, but no higher than the available stock.
The issue is that I have tried using the expression builder to get the value from a calculated query that has 2 fields - the ID and the value for that id, with criteria that is for the ID to get it from the main form, the sub-form, the combo box input and the query works.
But when trying to get it like this:
It shows an error "The expression [Query bla] you entered in the form control's ValidationRule property contains the error The object doesn't contain the Automation object 'Query bla'".
I tried using directly the table Value(but it won't work anyway as it doesn't know for which field to get the stock value from), still the same error. I guess it can't reference to anything else? Normal validation rules work, but I want to validate it not to exceed the value of the available stock for the item I am selling now.
Nowhere on the internet there is a tutorial how to do it with expression builder. How do people validate their fields then?
It doesn't stop me in this case to sell 200 items when I currently have stock of only 2 of them, for example.
Note: I have tried DlookUp in expression builder, straight up tells me No.
Sample wrong validation rule expression builder code:
<=[Query bla]![Stock]
<=[Items]![Stock]
I am currently using VBA and fetch the record I need(the current stock) with one of the following and my unbound text is changing on every subform to the same, it shouldn't happen like that. What can I use to populate a field for each record uniquely:
Private Sub ID_Product_IZBOR_Click()
'Me.Stock_ValueField = DLookup("[Nalichnost]", "Stoka", "[ID]=" & Me.ID_Product_IZBOR)
Me.Stock_ValueField = Me.ID_Product_IZBOR.Column(2)
End Sub
Partial solution: I created a new Dim as Integer and fetched the records based on the ID provided by the field in the form and used BeforeUpdate to validate the current stock. Unfortunately the only way to see the current stock level is to click on the combo box where you choose your product and check the column for that one, it doesn't show anywhere else :(
Don't use the expression builder (I NEVER do) - just type the needed expression in property.
>0 AND <=DLookup("Stock", "Items", "ID=" & [ID_Item])
Another approach is to return Stock in textbox ControlSource then ValidationRule references that textbox. Also, user can then see the quantity limit. Methods of pulling the Stock value from Items table:
include Stock field in Items combobox RowSource - textbox then references column by its index (index begins with 0): =[cbxItems].Column(2); VBA may be needed to Requery combobox after record entry/edit is committed to table.
include Items table in form RecordSource - bind textbox to Stock field (Locked yes and TabStop no)
DLookup() expression in textbox ControlSource
Use ValidationText property to give users a custom message.
However, ValidationRule will not prevent user not entering any value if they skip the control. If you want to make sure a value is entered, either set field as required in table or use form BeforeUpdate event to validate record data.

Opening a Record in a subform, based on selection in another subform

This is my first post, but often view this site to solve issues. Unfortuantely I have not been able to come up with a solution for my current development. I am working on a Task list with a different type of setup. The main form is a one stop shop for multiple users.
There are two tables
Team
- ID (autonum)
- First Name (text)
- Last Name (text)
- Full Name (Calculated)
Tasks
-ID (autonum)
- Task (short text)
- Description (Long Text)
- Start Date (short date)
- Assigned To (Lookup to Full Name)
- Etc (Additional fields)
The MainMenu (main form) is set up bound to the Team table. With a dropdown field to select a team member. The form has two subforms (CurrentTaskSub and NewTaskSub). Both Subforms are bound to Tasks. CurrentTaskSub is created from a query of Task where tasks are not complete and past the start date. NewTaskSub is a direct form of the task table.
When a name is selected it uses a parent/child relationship to filter the CurrentTaskSub to tasks assigned to that team member. That part works.
What I want to happen is when you select one of the tasks from CurrentTaskSub, it will populate in NewTaskSub to view all the info on the task and to change or update it. Then it will refresh both Subforms when a change is save in NewTaskSub whether that is completing a task, updating it, or creating a new task.
Here is what I have attempted:
On the CurrentTaskSub subform I select the task field and set that on click it will execute VBA code.
the current code of many I have tried is:
Forms!MainMenu![NewTaskSub].Form.Filter = "[Task] = " & Me.Task
Forms!MainMenu![NewTaskSub].Form.FilterOn = True
and
'With Forms(NewTaskSub).Recordset
'run a findfirst against that recordset
'NewTaskSub.FindFirst "[Task] = " & Me.Task
'if item not found issue warning
'If NewTaskSub.NoMatch Then MsgBox Me.Task & " not found"
'End With
Both these produce debug errors. I think I am on the right track but can seem to find the solution I am hoping for. Any assistance or advice is appreciated. Thank you.
Ok So after continued testing I have figured out the issue.
It was a minor problem and didn't need a lot of what I tried.
I am leaving this up though for others who may have similar issues.
I had to take the filter and add a requery so for this instance the code looks like this:
Me.Parent.Form.NewTaskSub.Form.Filter = "[ID]= " & Me.ID
Me.Parent.Form.NewTaskSub.Form.FilterOn = True
Me.Parent.Controls!NewTaskSub.Form.Requery

Getting value of previous selected item (dropDown)

When a user changes the selected item on a dropdown I need to get the PREVIOUS item selected,
EX:
dropdown items:
1) Questions
2) Jobs
3) Tags
4) Badges
User has #2 Selected and then changes to #4 -- How can I get the value of #2 when they change the selection?
Declare an instance variable in your form (WinForms) or window (WPF).
When a user selects an item:
Do what you want to do.
Save the current item index in the instance variable.
In step 1, you can now access the instance variable to get the previously selected item.
Declare a global variable that will contain the previous value.
When the user changes the selection in the combobox, set the variable to the currently selected value. Allow the selection to be changed. You now will have the previous value.
If you need to have the history of changes, then the global variable would be a collection. Then on changed event, add the current selection to the collection.
If your control is bound to data, there is no need to "Squirrel" the old value away, your data provider usually does this for you.
For example, if you are bound to a DataRow, this code will get the previous value.
? = [Your DataRow].item("[Your column name]",OrigialVersion)
This varies based on your data but ultimately, you could always re-query the database to get the original value as well.
Regardless of what you are bound too, if you ask the datasource for it's value during the Validating event of the control, it will have not changed yet so it will give you the old value, which you can then compare against the current selection.
Lastly, if you are not bound to data, I typically store the old value in the TAG property on the GotFocus event of the control. Then you can compare against that.
Hope this provides some other options that might help you, depending on your case.

Problems with Report Variables

I'm new to SSRS 2012 and have a question about variables. I have a report that retrieves order and order line information from our database (order #, order line #, item, quantity, etc). I need to add a textbox to the footer of the report that can only be displayed for certain items (i.e. if item # equals "123" then show textbox, otherwise hide it.
I added a report variable called 'ItemExists', and unchecked the read-only flag, and set the default value to 0.
I then added an expression to the textbox on the report footer to show it if variable=1, and to hide it if variable=0.
I'm trying to add a textbox with an expression to the body of the report (same group as where the item # is displayed), but I'm unable to get the report variable to update properly. Here's what I tried:
=IIF((Variables!ItemExists.Value = 0) and (Fields!item.Value = "123"), (Variables!ItemExists.SetValue(1)), Nothing)
This works if the value of the item is 123, but if the item is not equal to that value, it still sets the ItemExists variable to 1.
The reason I'm checking to see if the variable is equal to 0 is that there may be multiple lines in the report, and if any one of the items is a match, I want the variable to be set to 1.
I'm not sure if I'm way off track here, but if you could provide any assistance on the best way to achieve this, that would be great.
Thanks in Advance.

Sharepoint 2010: Update Lookup Field Multiple Value with a Workflow

I want to update a lookup field that contains multiple values through a Workflow, using Sharepoint Designer 2010.
For the moment, the old value is always overwritten, and I would like to "merge" the old value with the new one.
Here is the list of my test by so far:
1) I've managed to Keep the old or the new one, but not both of them.
2) I've tried to add key words like : & ; , between the fields, but only the first element is written in the list ( Example : [%first Element: id%] ;[% Second Element: ID%] --> Result in the column : First Element Id)
I'm out of idea. Do you have any tips?
Do you need more information?
Is this possible to do such things in Sharepoint designer?
Yes this can be done in SharePoint Designer. You need to set both the ID and the lookup value (the text that is displayed in the lookup field) - and these need to be separated by ;#
Build the following as a string before setting it to the lookup value.
[%Current Item:LookupList%];#[%Variable:NewItemID%];#[%Variable:NewItemTitle%]
In the example above, the first item is your original multi-select lookup list. The second, is the ID from the item that you want to add to the lookup, and the third is the title (or the value you're displaying in the field) from the item you're adding.