Tuesday, 10 November 2015

Programmatically adjusting the "toolbar type of a ListViewWebPart using Powershell script"

I have a requirement to hide new item or edit list in SharePoint list



$powershellSnapin = “Microsoft.Sharepoint.Powershell”
if ((Get-PSSnapin -Name $powershellSnapin -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin $powershellSnapin
}

try
    {
        $web= Get-SPWeb "url"  #url
       $webpartmanager = $web.GetLimitedWebPartManager("/Lists/1Contracts/AllItems.aspx", [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) #Get the webpart manager class

        for($i=0;$i -lt $webpartmanager.WebParts.Count;$i++)  
            {
                if($webpartmanager.WebParts[$i].title -eq "1Contracts")   #list title
                    {  
                        $wp=$webpartmanager.WebParts[$i]; 
                        #$wp.ChromeType="TitleAndBorder"; #If you want to change ChromeType,Uncomment #.  
                        
                        $wp.View.Toolbar = "AllItems" #Getting view
                        [xml]$x = $wp.XmlDefinition
                        $x.View.Toolbar.Type = "None" # or Standard, Full, Freeform #Toolbar types
                        $wp.View.SetViewXml($x.view.OuterXml)
                        $wp.View.Update()

                        $webpartmanager.SaveChanges($wp);  

                        break; 
                    }
    
            }
 
       $web.Dispose(); 
  }
  catch
    {
        Write-Host  Error  :  $_.exception
    }


Wednesday, 4 November 2015

SQL ROW_NUMBER OVER AND PARTITION BY

Table Name: myTable
Columns:

-->roll_no
-->classId
-->location

SQL Statements

--Get the count of rows based on columns

  SELECT *, ROW_NUMBER()OVER(PARTITION BY roll_no  ORDER BY subject DESC) rowCnt
    FROM myTable order by rowCnt desc
 
--Get the count of rows based on columns using where clause

 SELECT *, ROW_NUMBER()OVER(PARTITION BY roll_no  ORDER BY subject DESC) rowCnt
    FROM myTable
    where myTable.roll_no='1001'
 
--Query sub query data based on where clause  

    SELECT rid FROM(
 SELECT *, ROW_NUMBER()OVER(PARTITION BY roll_no  ORDER BY subject DESC) rowCnt
    FROM myTable
    where myTable.roll_no='1001'
)X WHERE classId= 7 and upper(location) != 'USA' and rowCnt = 1

Tuesday, 3 November 2015

Create ListView using SharePoint PowerShell script



#Passing My Site Url
param($serverUrl)

#Begin arguments validation

if($serverUrl -eq $null)
{
$argErr = $true
}

if($argErr)
{
Write-Host
Write-Host -ForegroundColor Red "One or more parameters missing or invalid. Please see the usage and give the proper parameters"
Write-Host
Write-Host "Usage: Creating List View  messages"
Write-Host
   
    exit
}

try

{

$web = Get-SPWeb -Identity $serverUrl

Write-host
Write-host  "------Getting  List-----"
Write-host

$list = $web.Lists["Demo Ticket"]


Write-host
Write-host  "------  Making Query -----"
Write-host

$ViewName =  "Demoview" #My View Name
     
        $Query = "<Where><Eq><FieldRef Name='AssignedTo'/><Value Type='Integer'><UserID /></Value></Eq></Where>"

Write-host
Write-host  "------Getting Fields for View-----"
Write-host

$fields = $list.Views["All Items"].ViewFields.ToStringCollection()

$viewRowLimit = 50   #Row Limit
$viewPaged = $true #Paged property
$viewDefaultView = $false   #DefaultView property

Write-host
Write-host  "------Adding View  to list-----"
Write-host

$result = $list.Views.Add($ViewName, $fields, $Query, $viewRowLimit, $viewPaged, $viewDefaultView)

Write-host
Write-host  "---- Updating list -----"
Write-host

$list.Update()

Write-host
Write-host  "----- Successfully Added View to  List -Demo View  -----"
Write-host

$web.Update()
}
catch [System.SystemException]
{
  write-host "Execution stopped due to: "+$_.Message -foregroundcolor Red
}




Monday, 26 October 2015

Aras Innovator promote item

1.Part has created. (With state as Preliminary)
2.Promote the item using AML.
<AML>
  <Item type="Part" action="promoteItem" where="[PART].item_number='test133' and [PART].is_current='1' and [PART].state='preliminary'">
     <state>Released</state>
  </Item>
</AML>

Tuesday, 13 October 2015

File upload error for Type:Part Number:P001 Name: Rev:A-1 FileName:test.docx ActualFileName:C:\test.docx Error: Database Name Or Database Description Is Wrong.(Check your request and server configuration file)

Error: File upload error for Type:Part Number:P001 Name: Rev:A-1 FileName:test.docx ActualFileName:C:\test.docx Error: Database Name Or Database Description Is Wrong.(Check your request and server configuration file)


Root cause:
Your vault server name is wrong.

Solution:
Go to aras web ui.
AdministrationFile handlingVault
Search -->Default
Check the value.
Vault URL, should your right target server vault url.

How can you get exact url.

Go to Aras innovator SQL Server.
SELECT * FROM [innovator].[VAULT]

Copy [VAULT_URL_PATTERN] value
Update in innovator we ui, go to AdministrationFile handlingVault Search Default

Now try, your problem should be resolve.

Wednesday, 7 October 2015

Thursday, 1 October 2015

Error : 'SOAP-ENV' is an undeclared prefix. Line 1, position 2.

Error : 'SOAP-ENV' is an undeclared prefix. Line 1, position 2.
Solution:
Innovator is not allowing to login, check the Innovator URL, User ID, Password.